mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-14 00:47:30 +00:00
76dc849fca
The type system no longer guarantees that the input string is nul-terminated, meaning accessing beyond the range-checked `i` a char-at-a-time is no longer safe. (In C++, we would either be using a plain C string which is always nul-terminated or we would be using (w)string::cstr() which similarly grants access to its nul-terminated buffer.) Aside from that, there's no need to explicitly check `if c2 == '\0'` because '\0' is not a valid hex digit so the `?` tacked on to `convert_hex_digit(c2)?` will abort and return `None` anyway. convert_hex_digit() is not appreciably faster than char::to_digit(16) and makes the code less maintainable since it encodes certain assumptions; since it's also not used consistently just drop it in favor of the std fn. Since the output string (per the decode logic) is always shorter than or equal to the input string, just reserve the input string size upfront to prevent vec reallocations. |
||
---|---|---|
.. | ||
src | ||
widestring-suffix | ||
build.rs | ||
Cargo.lock | ||
Cargo.toml |