refactor: switch StringBuilder capacity to size_hint
- Replace the StringBuilder(capacity=...) argument with size_hint=... in base32, base64, hex, SAM quoting/parsing. - Drop trailing commas after the last field in I2NP, NTCP2 and tunnel fragment enum variants (formatter cleanup). - No behavior change; encoded output and parsed fields are unchanged.
This commit is contained in:
1 parent
cadb8cd898
commit
274bb319ab
7 files changed
+12
-12
No files matched your search
+3
-3
@@ -69,7 +69,7 @@ fn quote_value(s : String) -> String {
|
||||
if !needs_quoting(s) {
|
||||
return s
|
||||
}
|
||||
let buf = StringBuilder(capacity=s.length() + 2)
|
||||
let buf = StringBuilder(size_hint=s.length() + 2)
|
||||
buf.write_char('"')
|
||||
for ch in s {
|
||||
if ch == '"' || ch == '\\' {
|
||||
@@ -175,11 +175,11 @@ fn split_kv(token : String) -> (String, String)? {
|
||||
if eq_idx <= 0 {
|
||||
return None
|
||||
}
|
||||
let kbuf = StringBuilder(capacity=eq_idx)
|
||||
let kbuf = StringBuilder(size_hint=eq_idx)
|
||||
for i = 0; i < eq_idx; i = i + 1 {
|
||||
kbuf.write_char(chars[i])
|
||||
}
|
||||
let vbuf = StringBuilder(capacity=chars.length() - eq_idx - 1)
|
||||
let vbuf = StringBuilder(size_hint=chars.length() - eq_idx - 1)
|
||||
for i = eq_idx + 1; i < chars.length(); i = i + 1 {
|
||||
vbuf.write_char(chars[i])
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user