(&mut self, name: &str)
| 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 | } |