Hi

I'm trying to remove all CRLFs from a large string in Javascript
(decode e-mail attachment in a Firefox extension). At first I tried:
text = text.replace(/\r\n/g, "");
But on 3Mb size string this command took 20 seconds. Then I tried to
do:
var array = text.split(/\r\n/);
text = array.join("");
The split() takes less than a second, but join() again takes 15
seconds. Seems that string concatenation is very slow in Javascript.
What I have come up to is to do split(), then write resulting array
into a temporary file, and then read the file. Writing file takes
about 5 seconds. Reading is quite fast.
Is there any better way to do fast string concatenation in Firefox
Extension?
And also, when I have written temp file, and I'm getting file.fileSize
property, it retuns 0, why?

Thanks,
telega

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to