MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / ensure_capacity

Method ensure_capacity

src/protocol/buffer_writer.rs:29–39  ·  view source on GitHub ↗
(&mut self, additional: usize)

Source from the content-addressed store, hash-verified

27 }
28
29 fn ensure_capacity(&mut self, additional: usize) {
30 if self.buffer.len() - self.offset < additional {
31 let old_len = self.buffer.len();
32 // Exponential growth ~1.5x as in TS implementation.
33 let mut new_len = old_len + (old_len >> 1) + additional;
34 if new_len == old_len {
35 new_len += additional;
36 }
37 self.buffer.resize(new_len, 0);
38 }
39 }
40
41 fn write_be_bytes(&mut self, bytes: &[u8]) {
42 let len = bytes.len();

Callers 2

write_be_bytesMethod · 0.80
add_stringMethod · 0.80

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected