Răsfoiți Sursa

decode size hint: Fix lower boundary

The size of a decoded URI can shrink only in fixed steps of 3 byte
("%xx") to 1 byte, thus the resulting size is always rounded up (2 bytes
can not shrink any further), which is most easily implemented in integer
division by adding `divisor - 1`.
chrysn 6 ani în urmă
părinte
comite
7aaea8fae6
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  1. 1 1
      percent_encoding/lib.rs

+ 1 - 1
percent_encoding/lib.rs

@@ -368,7 +368,7 @@ impl<'a> Iterator for PercentDecode<'a> {
 
     fn size_hint(&self) -> (usize, Option<usize>) {
         let bytes = self.bytes.len();
-        (bytes / 3, Some(bytes))
+        ((bytes + 2) / 3, Some(bytes))
     }
 }