A vibe coded tangled fork which supports pijul.

patchutil: pre-compile splitFormatPatch regex at package init

Signed-off-by: Matías Insaurralde <matias@insaurral.de>

authored by

Matías Insaurralde and committed by tangled.org 6631f27b 2677d2b1

+3 -3
+3 -3
patchutil/patchutil.go
··· 47 47 EmptyPatchError error = errors.New("patch is empty") 48 48 GenericPatchError error = errors.New("patch is invalid") 49 49 FormatPatchError error = errors.New("patch is not a valid format-patch") 50 + 51 + formatPatchSplitRe = regexp.MustCompile(`(?m)^From [0-9a-f]{40} .*$`) 50 52 ) 51 53 52 54 func IsPatchValid(patch string) error { ··· 115 117 } 116 118 117 119 func splitFormatPatch(patchText string) []string { 118 - re := regexp.MustCompile(`(?m)^From [0-9a-f]{40} .*$`) 119 - 120 - indexes := re.FindAllStringIndex(patchText, -1) 120 + indexes := formatPatchSplitRe.FindAllStringIndex(patchText, -1) 121 121 122 122 if len(indexes) == 0 { 123 123 return []string{}