| 30 | self.n(role + 1, p.pos.into()); |
| 31 | } |
| 32 | fn path(&mut self, path: &str) -> FormatResult<()> { |
| 33 | charge(&mut self.budget, path.len(), 1)?; |
| 34 | let id = if let Some(&id) = self.paths.get(path) { |
| 35 | id |
| 36 | } else { |
| 37 | if self.dictionary.len() >= 1_000_000 { |
| 38 | return Err(FormatError::GraphFieldLimitExceeded); |
| 39 | } |
| 40 | charge(&mut self.budget, 1, 128)?; |
| 41 | charge(&mut self.budget, path.len(), 2)?; |
| 42 | let id = self.dictionary.len() as u32; |
| 43 | self.dictionary.push(path.into()); |
| 44 | self.paths.insert(path.into(), id); |
| 45 | id |
| 46 | }; |
| 47 | self.n(PATH, id.into()); |
| 48 | Ok(()) |
| 49 | } |
| 50 | fn local(&mut self, role: usize, local: &Local) -> FormatResult<()> { |
| 51 | self.path(&local.path)?; |
| 52 | self.n(LOCAL + role, local.line); |