Hi all,
we cleaned up the Segment class implementation such that our (and your) code becomes more readable and less error prone.
For example, the "assign" function did two different things, depending on whether or not the corresponding segment was already assigned to a string. For the following example:
String<char> text = "ABCDEFGH";
Segment< String<char>, InfixSegment> inf;
assign(inf, infix(text, 2, 5));
assign(inf, infix(text, 5, 8));
the first assign function would assign text to inf as the underlying string, while the second
assign would assign the values from text[5:7] to text[2:6]. Therefore,
text was changed to "ABFGHFGH".
Since this behavior is not obvious and you might not able to tell what is happening we removed the second alternative, such that the assign function always sets the underlying string of an segment and does not change the underlying string at any time.
In addition, we also remove every function working on segments which changed the underlying string, such as append, appendValue, resize, replace … The reason for this is, that you are able to use those functions directly on the underlying string. Using
the functions directly on the underlying string makes your intention obvious and the code easier to read.
If you have any questions just write an email.
Cheers,
Jochen
|