MCPcopy Create free account
hub / github.com/Glyphack/enderpy / alloc

Method alloc

parser/src/intern.rs:56–70  ·  view source on GitHub ↗
(&mut self, name: &str)

Source from the content-addressed store, hash-verified

54 self.vec[id.0 as usize]
55 }
56 unsafe fn alloc(&mut self, name: &str) -> &'static str {
57 let cap = self.buf.capacity();
58 if cap < self.buf.len() + name.len() {
59 let new_cap = (cap.max(name.len()) + 1).next_power_of_two();
60 let new_buf = String::with_capacity(new_cap);
61 let old_buf = mem::replace(&mut self.buf, new_buf);
62 self.full.push(old_buf);
63 }
64 let interned = {
65 let start = self.buf.len();
66 self.buf.push_str(name);
67 &self.buf[start..]
68 };
69 &*(interned as *const str)
70 }
71}

Callers 1

internMethod · 0.80

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected