Add a line credit (will merge with adjacent ranges if possible).
(&mut self, line: u64, credit: Credit)
| 631 | |
| 632 | /// Add a line credit (will merge with adjacent ranges if possible). |
| 633 | pub fn add_line(&mut self, line: u64, credit: Credit) { |
| 634 | self.stats_cache = None; // Invalidate cache |
| 635 | |
| 636 | // Try to extend the last range |
| 637 | if let Some(last) = self.ranges.last_mut() { |
| 638 | if last.try_extend(line, &credit) { |
| 639 | return; |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | // Create new range |
| 644 | self.ranges.push(CreditRange::single(line, credit)); |
| 645 | } |
| 646 | |
| 647 | /// Add a range of lines with the same credit. |
| 648 | pub fn add_range(&mut self, start: u64, end: u64, credit: Credit) { |