diff options
author | zeripath <art27@cantab.net> | 2021-06-17 11:35:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-17 11:35:05 +0100 |
commit | 0db1048c3ab0b0802779fd84b86c4335c37e54b3 (patch) | |
tree | 642c73f6ec0647b3e2c71a76397401359ad77cdb /modules/emoji | |
parent | 6ad5d0a3062966515730aa1f8d62db5d2a7704ee (diff) | |
download | gitea-0db1048c3ab0b0802779fd84b86c4335c37e54b3.tar.gz gitea-0db1048c3ab0b0802779fd84b86c4335c37e54b3.zip |
Run processors on whole of text (#16155)
There is an inefficiency in the design of our processors which means that Emoji
and other processors run in order n^2 time.
This PR forces the processors to process the entirety of text node before passing
back up. The fundamental inefficiency remains but it should be significantly
ameliorated.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/emoji')
-rw-r--r-- | modules/emoji/emoji.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/emoji/emoji.go b/modules/emoji/emoji.go index 01fb764ce3..85df2d6973 100644 --- a/modules/emoji/emoji.go +++ b/modules/emoji/emoji.go @@ -6,6 +6,7 @@ package emoji import ( + "io" "sort" "strings" "sync" @@ -145,6 +146,8 @@ func (n *rememberSecondWriteWriter) Write(p []byte) (int, error) { if n.writecount == 2 { n.idx = n.pos n.end = n.pos + len(p) + n.pos += len(p) + return len(p), io.EOF } n.pos += len(p) return len(p), nil @@ -155,6 +158,8 @@ func (n *rememberSecondWriteWriter) WriteString(s string) (int, error) { if n.writecount == 2 { n.idx = n.pos n.end = n.pos + len(s) + n.pos += len(s) + return len(s), io.EOF } n.pos += len(s) return len(s), nil |