From 64652fc81d535b42b6d04d36bae56574c4aad542 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Sun, 5 Apr 2026 15:58:40 +0200 Subject: [PATCH] fix(scope): no new string allocation to count characters --- src/commit/types/scope.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/commit/types/scope.rs b/src/commit/types/scope.rs index 2ad88f4..6510317 100644 --- a/src/commit/types/scope.rs +++ b/src/commit/types/scope.rs @@ -61,7 +61,11 @@ impl Scope { /// Returns the visible length of the header segment pub fn header_segment_len(&self) -> usize { - self.header_segment().chars().count() + if self.is_empty() { + 0 + } else { + self.0.chars().count() + 2 + } } }