Files
Gitea/modules/charset/escape_status.go
T
Shudhanshu Singh d87d26d735 perf(gitdiff): optimize inline diff highlighting using cache (#38706)
This pull request optimizes code diff highlighting in the PR Files
Changed view, which is a major CPU bottleneck and hot path in
production.

Previously, Gitea executed the expensive `DiffMatchPatch` algorithm
twice for every matching deleted/added line pair (once for the deleted
line, and once for the added line). We now run the diff algorithm once
and cache the resulting `DiffInline` on the `DiffLine` struct itself,
allowing the second line to render via a 0-cost cache lookup.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2026-07-30 16:43:36 +00:00

18 lines
554 B
Go

// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package charset
// EscapeStatus represents the findings of the Unicode escaper
type EscapeStatus struct {
Escaped bool // it means that some characters were escaped, and they can also be unescaped back
HasInvisible bool
HasAmbiguous bool
}
func (st *EscapeStatus) Combine(other *EscapeStatus) {
st.Escaped = st.Escaped || other.Escaped
st.HasAmbiguous = st.HasAmbiguous || other.HasAmbiguous
st.HasInvisible = st.HasInvisible || other.HasInvisible
}