kjetil
January 17, 2007, 5:12pm
1
I wonder if it would be possible to change
for (int j = 0; j < i; ++j)
result += (juce_wchar) (unsigned char) data[j];
into
result+=String(data);
?
If not, createStringFromData spends really long time if data is very large. This is a big problem when loading large image resources into the jucer on linux.
jules
January 17, 2007, 5:21pm
2
Ah yes, that would be slow. (hmm - in fact, that’s probably why the linux juce demo is slower to load the SVG images than the windows one)
An even faster version would be something like this:
[code] tchar* const dst = const_cast <tchar*> ((const tchar*) result);
for (int j = 0; j <= i; ++j)
dst[j] = (juce_wchar) (unsigned char) data[j];
[/code]
kjetil
January 17, 2007, 5:33pm
3
[quote=“jules”]Ah yes, that would be slow. (hmm - in fact, that’s probably why the linux juce demo is slower to load the SVG images than the windows one)
An even faster version would be something like this:
[code] tchar* const dst = const_cast <tchar*> ((const tchar*) result);
for (int j = 0; j <= i; ++j)
dst[j] = (juce_wchar) (unsigned char) data[j];
[/code][/quote]
Wow, this really sped up the start up time for jucedemo!
I had to make this modification though:
tchar* const dst = const_cast <tchar*> ((const tchar*) result);
int j;
for (j = 0; j <= i; ++j)
dst[j] = (juce_wchar) (unsigned char) data[j];
dst[j]=0;
result=String(dst);
jules
January 17, 2007, 5:38pm
4
ah yes, I just typed it in without actually trying it. You don’t need the “result =” line at the end though.
whau ! this really speeds up svg loading a lot ! nice one kjetil !
kjetil
January 19, 2007, 1:09am
6
It doesn’t seem to quite work. When saving files in the jucer, it puts 0-4 random-like extra charactors at the end of the file.
jules
January 19, 2007, 9:33am
7
You left a “<=” in there. Try this:
[code] String result;
result.preallocateStorage (i + 1);
tchar* const dst = const_cast <tchar*> ((const tchar*) result);
for (int j = 0; j < i; ++j)
dst[j] = (juce_wchar) (unsigned char) data[j];
dst[i] = 0;
return result;[/code]
kjetil
January 19, 2007, 12:50pm
8
[quote=“jules”]You left a “<=” in there. Try this:
[code] String result;
result.preallocateStorage (i + 1);
tchar* const dst = const_cast <tchar*> ((const tchar*) result);
for (int j = 0; j < i; ++j)
dst[j] = (juce_wchar) (unsigned char) data[j];
dst[i] = 0;
return result;[/code][/quote]
Thanks.