| 110 | } |
| 111 | |
| 112 | fn bytes(&mut self, bytes: &[u8], offset: Option<usize>) { |
| 113 | // Range references never stand in for a token's kind or identity. |
| 114 | let (tag, at) = if let Some(at) = offset { |
| 115 | if at == self.s.content_cursor { |
| 116 | (0, at) |
| 117 | } else { |
| 118 | (1, at) |
| 119 | } |
| 120 | } else { |
| 121 | let at = *self.literals.entry(bytes.to_vec()).or_insert_with(|| { |
| 122 | let at = self.c.literals.len(); |
| 123 | self.c.literals.extend_from_slice(bytes); |
| 124 | at |
| 125 | }); |
| 126 | (2, at) |
| 127 | }; |
| 128 | put(&mut self.c.control, tag); |
| 129 | put(&mut self.c.control, bytes.len() as u64); |
| 130 | if tag != 0 { |
| 131 | delta(&mut self.c.references, &mut self.s.reference, at as u64); |
| 132 | } |
| 133 | if tag != 2 { |
| 134 | self.s.content_cursor = at + bytes.len(); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | fn leaves( |
| 139 | &mut self, |