refactor: use the built-in max/min to simplify the code (#10657)

Signed-off-by: alaningtrump <alaningtrump@outlook.com>
This commit is contained in:
alaningtrump
2026-07-03 23:59:26 +08:00
committed by GitHub
parent 7a3583b52c
commit 80ec22945a

View File

@@ -461,10 +461,7 @@ func (p *RuleParser) parse(arena *Arena, ctx *ParseContext, start int) ParseResu
if result.Type != Fail {
text := ""
if result.Start < len(ctx.Input) {
end := result.End
if end > len(ctx.Input) {
end = len(ctx.Input)
}
end := min(result.End, len(ctx.Input))
text = ctx.Input[result.Start:end]
}
@@ -514,10 +511,7 @@ func (p *TagParser) parse(arena *Arena, ctx *ParseContext, start int) ParseResul
if result.Type != Fail {
text := ""
if result.Start < len(ctx.Input) {
end := result.End
if end > len(ctx.Input) {
end = len(ctx.Input)
}
end := min(result.End, len(ctx.Input))
text = ctx.Input[result.Start:end]
}