From: Jean Privat Date: Thu, 28 Apr 2016 23:04:49 +0000 (-0400) Subject: Merge: Faster ASCII-only strings X-Git-Url: http://nitlanguage.org Merge: Faster ASCII-only strings This simple PR re-introduces the concept of ASCII strings for faster no-overhead accesses to random characters in a string. The class is private as it is to be used only internally, no client should care for the specific type of a String and all performance improvements will be automatic, should the optimization be possible. Since we are dealing with UTF-8, the only case where O(1) access can efficiently and without much overhead (one `if` statement at creation) be determined, is when a string only contains ASCII characters. Note that since the Buffer can change access semantics depending on what is appended during its lifetime, no ASCII-only FlatBuffer has been added. This is implemented here by introducing two subclasses of FlatString, one for ASCII only strings, and one for regular Unicode strings (the old FlatString). In terms of performance, in the compiler, there is a ~0.5% improvement, but in specific cases like JSON parsing for the `big_gov_data.json` (where not a single unicode character is present) bench, the difference amounts to ~35%. Pull-Request: #2040 Reviewed-by: Jean Privat --- aa7736b205566a6bf9ab05678b79d5a9215a78a9