mirror of
https://github.com/penpot/penpot.git
synced 2025-05-14 14:46:40 +02:00
⚡ Add minor optimizations to data-uri->blob helper
This commit is contained in:
parent
4f23852bca
commit
91224e5274
1 changed files with 5 additions and 3 deletions
|
@ -74,14 +74,16 @@
|
||||||
|
|
||||||
(defn data-uri->blob
|
(defn data-uri->blob
|
||||||
[data-uri]
|
[data-uri]
|
||||||
(let [[mtype b64-data] (str/split data-uri ";base64,")
|
(let [[mtype b64-data] (str/split data-uri ";base64," 2)
|
||||||
mtype (subs mtype (inc (str/index-of mtype ":")))
|
mtype (subs mtype (inc (str/index-of mtype ":")))
|
||||||
decoded (.atob js/window b64-data)
|
decoded (.atob js/window b64-data)
|
||||||
size (.-length ^js decoded)
|
size (.-length ^js decoded)
|
||||||
content (js/Uint8Array. size)]
|
content (js/Uint8Array. size)]
|
||||||
|
|
||||||
(doseq [i (range 0 size)]
|
(loop [i 0]
|
||||||
(aset content i (.charCodeAt ^js decoded i)))
|
(when (< i size)
|
||||||
|
(aset content i (.charCodeAt ^js decoded i))
|
||||||
|
(recur (inc i))))
|
||||||
|
|
||||||
(create-blob content mtype)))
|
(create-blob content mtype)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue