mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
http: make response sending more efficient by avoiding some copies
This commit is contained in:
parent
9ba72ce3fd
commit
84d57c1c86
4 changed files with 51 additions and 44 deletions
|
|
@ -222,35 +222,3 @@ impl TorrentMaps {
|
|||
pub struct State {
|
||||
pub access_list: Arc<AccessListArcSwap>,
|
||||
}
|
||||
|
||||
pub fn num_digits_in_usize(mut number: usize) -> usize {
|
||||
let mut num_digits = 1usize;
|
||||
|
||||
while number >= 10 {
|
||||
num_digits += 1;
|
||||
|
||||
number /= 10;
|
||||
}
|
||||
|
||||
num_digits
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_num_digits_in_usize() {
|
||||
let f = num_digits_in_usize;
|
||||
|
||||
assert_eq!(f(0), 1);
|
||||
assert_eq!(f(1), 1);
|
||||
assert_eq!(f(9), 1);
|
||||
assert_eq!(f(10), 2);
|
||||
assert_eq!(f(11), 2);
|
||||
assert_eq!(f(99), 2);
|
||||
assert_eq!(f(100), 3);
|
||||
assert_eq!(f(101), 3);
|
||||
assert_eq!(f(1000), 4);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue