[Issue 11017] std.string/uni.toLower is very slow
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 12 11:59:09 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11017
Dmitry Olshansky <dmitry.olsh at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dmitry.olsh at gmail.com
--- Comment #1 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-09-12 11:59:08 PDT ---
(In reply to comment #0)
> char[] s = new char[10_000_000];
> s[] = 'A';
> auto s2 = s.toLower;
>
> This takes 4.3 seconds on my machine.
>
>
> char[] s = new char[10_000_000];
> s[] = 'A';
> auto s2 = s.map!toLower.to!string;
>
> This only takes 1.1 seconds.
>
There 2 things here to consider - first the 2nd one is not correct in general
(1 codepoint can map to many e.g. german sharp S).
> Looking at the code for std.uni.toLower, it appears the string is constructed
> using repeated ~=. It should use an Appender of some sort.
This indeed could be fixed I do suspect put an optimisitc
reserve(original.length) there would work even better. See also issue 10864:
http://d.puremagic.com/issues/show_bug.cgi?id=10864
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list