Bug 6064 – std.array.join is unnecessarily slow for strings
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-05-27T13:40:00Z
Last change time
2011-07-16T17:58:00Z
Keywords
performance
Assigned to
issues.dlang
Creator
dlang-bugzilla
Comments
Comment #0 by dlang-bugzilla — 2011-05-27T13:40:32Z
std.array.join(x) does not special-case for strings. This causes joined strings to be copied character-by-character.
std.array.join(x,x) does attempt to special-case for strings, but only when only the first argument is a string - and even then, this doesn't work:
C:\...\std\array.d(778): Error: template std.algorithm.copy(Range1,Range2) if (isInputRange!(Range1) && isOutputRange!(Range2,ElementType!(Range1))) does not match any function template declaration
C:\...\std\array.d(778): Error: template std.algorithm.copy(Range1,Range2) if (isInputRange!(Range1) && isOutputRange!(Range2,ElementType!(Range1))) cannot deduce template function from argument types !()(Result,string)
test.d(9): Error: template instance std.array.join!(string[],Map!(result,string)) error instantiating
Program:
import std.array;
import std.algorithm;
void main()
{
string[] arr;
string sep;
join(arr, map!"a"(sep));
}