Construct a RCXString from a slice s.
A destructor is present on this object, but not explicitly documented in the source.
A postblit is present on this object, but not explicitly documented in the source.
Returns the length of the string
Returns the last code point of this.
Returns the maximum number of character this string can store without requesting more memory.
Returns true iff this is empty
Returns the first code point of this.
Returns the length of the string
Returns the concatenation of this with s.
Returns the concatenation of s with this.
Returns the nth code unit in this.
Appends s to this.
Returns a slice to the entire string or a portion of it.
Discards the last code point
Discards the first code point
Needed for correct printing in other modules
verify UTF-8 storage
string s = "åäö"; RCString rcs = s; assert(rcs.length == 6); import std.algorithm : count; assert(rcs.count == 3); assert(rcs.front == 'å'); rcs.popFront(); assert(rcs.front == 'ä'); rcs.popFront(); assert(rcs.front == 'ö'); rcs.popFront(); assert(rcs.empty);
shows performance increase for SSO over built-in string
1 enum maxSmallSize = 23; 2 alias S = RCXString!(immutable char, maxSmallSize); 3 4 import std.datetime: StopWatch, Duration; 5 import std.conv : to; 6 import std.stdio; 7 8 enum n = 2^^21; 9 10 StopWatch sw; 11 12 sw.reset; 13 sw.start; 14 char[maxSmallSize] ss; 15 foreach (i; 0 .. n) 16 { 17 auto x = S(ss); 18 } 19 sw.stop; 20 auto timeRCString = sw.peek().msecs; 21 writeln("> RCString took ", sw.peek().to!Duration); 22 23 sw.reset; 24 sw.start; 25 foreach (i; 0 .. n) 26 { 27 string x = ss.idup; 28 } 29 sw.stop; 30 auto timeString = sw.peek().msecs; 31 writeln("> Builtin string took ", sw.peek().to!Duration); 32 33 writeln("> Speedup: ", timeString/timeRCString);
Reference Counted Array. Configured with character type E, maximum length for the small string optimization, and the allocation function, which must have the same semantics as realloc.