Minor string optimizations
This MR contains two changes related to String usage:
- Change
utils::string_from_bytesto validate UTF-8 string first and then do heap allocation. This avoids unnecessary memory allocation and memory copy with invalid strings. - Switch from
utils::string_from_bytestostr::from_utf8in places where&stris enough andStringis unnecessary. This avoid copying data to pass astrreference forward.
-
I agree to release my code and all other changes of this MR under the Apache-2.0 license