Fixed-width strings: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
mNo edit summary
Line 53: Line 53:


When a string is flattened, its two String pointers are replaced with a flat data buffer. The resulting width of the string is determined by the widths of the strings in the tree. Usually, the resulting string width is the widest of all substrings found. If desired (with an #ifdef), substrings could also be analyzed if they are wider than the containing data, if e.g. a 16-bit strings only contains 8-bit characters. This is, of course, a performance hit, but may be desired if memory footprint is important, because flattening the concatenation of a, say, 8-bit string and a 16-bit string may result in a 8-bit string if the flattener is allowed to check the contents of the 16-bit string.
When a string is flattened, its two String pointers are replaced with a flat data buffer. The resulting width of the string is determined by the widths of the strings in the tree. Usually, the resulting string width is the widest of all substrings found. If desired (with an #ifdef), substrings could also be analyzed if they are wider than the containing data, if e.g. a 16-bit strings only contains 8-bit characters. This is, of course, a performance hit, but may be desired if memory footprint is important, because flattening the concatenation of a, say, 8-bit string and a 16-bit string may result in a 8-bit string if the flattener is allowed to check the contents of the 16-bit string.
16-bit strings containing surrogate pairs will never be widened to 32 bits, losing surrogate pairs, because this would change the string length and the location of its characters.


=== Thread safety ===
=== Thread safety ===
55

edits

Navigation menu