Construct a RCXString from a slice s.
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
enum maxSmallSize = 23; alias S = RCXString!(immutable char, maxSmallSize); import std.datetime: StopWatch, Duration; import std.conv : to; import std.stdio; enum n = 2^^21; StopWatch sw; sw.reset; sw.start; char[maxSmallSize] ss; foreach (i; 0 .. n) { auto x = S(ss); } sw.stop; auto timeRCString = sw.peek().msecs; writeln("> RCString took ", sw.peek().to!Duration); sw.reset; sw.start; foreach (i; 0 .. n) { string x = ss.idup; } sw.stop; auto timeString = sw.peek().msecs; writeln("> Builtin string took ", sw.peek().to!Duration); 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.