From: Jean Privat Date: Tue, 15 Sep 2015 16:57:16 +0000 (-0400) Subject: Merge: Clean UTF-8 string update X-Git-Tag: v0.7.8~23 X-Git-Url: http://nitlanguage.org Merge: Clean UTF-8 string update Since quite some time now we've had the cleaning function for Bytes that ensured that what was coming from the exterior was clean and could be transformed safely to a String. This is now generalized to any NativeString, and the clean function will be called each time a NativeString is `to_s`'d At the same time, `clean_utf8` is now better performing (for `Files::read_all`, Ir per call is roughly 40% less than before), which limits the impacts of the new strategy. Furthermore, the string produced by `NativeString::clean_utf8` has its length calculated which saves time on later operations on the string. It also limits the number of calls by avoiding allocations if not necessary (if the string is already clean, which should happen a lot more often than not). As for performances, Valgrind `./bin/nitc src/nitc.nit`: Before: 14.040 GIr After: 13.859 GIr Time, best of 10 for `./bin/nitc src/nitc.nit -o bin/nitc`: Before: 0m4.989s After: 0m4.933s Time, best of 10 for `./bin/nitc --semi-global src/nitc.nit -o bin/nitc`: Before: 0m4.696s After: 0m4.691s Pretty much equivalent in real time, and a bit better in Valgrind, not bad considering every String is now cleaner than ever ! Pull-Request: #1705 Reviewed-by: Jean Privat Reviewed-by: Alexis Laferrière --- 827c9eae6ce5afff368c39d97d0bc8b95007c16c