Skip to content

Commit 52a0c34

Browse files
committed
Commit phrasing
1 parent 724695d commit 52a0c34

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

pkg/commitremap/commitremap.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func ParseCommitMap(filePath string) (map[string]string, error) {
6666
//
6767
// Each file is scanned byte-by-byte using a sliding window that matches
6868
// SHA-length hex sequences against the commit map. SHAs are replaced
69-
// wherever they appear — including inside URLs, markdown, or composite strings.
69+
// wherever they appear — including inside URLs, markdown, etc.
7070
//
7171
// numWorkers controls how many goroutines process files in parallel.
7272
// If numWorkers <= 0, it defaults to runtime.NumCPU().
@@ -154,11 +154,9 @@ func updateMetadataFile(filePath string, commitMap map[string]string, shaLen int
154154
return count, nil
155155
}
156156

157-
// hexTable is a branchless lookup table for valid hex bytes.
158-
// A single array index replaces the 6-comparison branch chain in isHexByte,
159-
// improving throughput in the per-byte hot loop.
160157
var hexTable [256]bool
161158

159+
// init initializes the hexTable with valid hexadecimal characters (valid sha1 and sha256 characters).
162160
func init() {
163161
for _, b := range []byte("0123456789abcdefABCDEF") {
164162
hexTable[b] = true
@@ -196,7 +194,7 @@ func commitMapSHALen(commitMap map[string]string) (int, error) {
196194
//
197195
// Algorithm:
198196
// 1. Walk each byte, counting consecutive valid hex (SHA) bytes.
199-
// 2. When a non-hex byte is hit, reset the counter no SHA can span it.
197+
// 2. When a non-hex byte is hit, reset the counter, no SHA can span it.
200198
// 3. Once we have shaLen consecutive hex bytes, extract that window and
201199
// look it up in commitMap.
202200
// 4. On match: replace in-place, skip past the replaced bytes. The next
@@ -229,12 +227,6 @@ func replaceSHABytes(data []byte, commitMap map[string]string, shaLen int) ([]by
229227
if newSHA, ok := commitMap[candidate]; ok {
230228
copy(data[start:i+1], newSHA)
231229
count++
232-
// Skip past the replaced bytes. Since we just wrote shaLen
233-
// bytes, the next possible SHA starts at i+1. Setting
234-
// consecutiveHex to 0 means the loop will begin counting
235-
// fresh from the next byte without re-scanning the
236-
// replacement. The loop increment (i++) moves us to i+1
237-
// automatically.
238230
consecutiveHex = 0
239231
}
240232
// If no match, consecutiveHex keeps growing and the window

0 commit comments

Comments
 (0)