Convert EOL to UNIX-style to render MD properly #8925
Labels
No Label
backport/done
backport/v1.0
backport/v1.1
backport/v1.10
backport/v1.11
backport/v1.12
backport/v1.13
backport/v1.14
backport/v1.15
backport/v1.2
backport/v1.3
backport/v1.4
backport/v1.5
backport/v1.6
backport/v1.7
backport/v1.8
backport/v1.9
bounty
changelog
dependencies
frontport/done
frontport/main
good first issue
Hacktoberfest
hacktoberfest-accepted
in progress
kind/api
kind/breaking
kind/bug
kind/build
kind/deployment
kind/deprecated
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/misc
kind/moderation
kind/package
kind/proposal
kind/question
kind/refactor
kind/regression
kind/security
kind/summary
kind/testing
kind/translation
kind/ui
kind/upstream-related
kind/usability
kind/ux
lgtm/done
lgtm/need 1
lgtm/need 2
performance/bigrepo
performance/cpu
performance/memory
performance/speed
priority/critical
priority/low
priority/maybe
priority/medium
proposal/rejected
reviewed/confirmed
reviewed/duplicate
reviewed/fixed
reviewed/invalid
reviewed/not-a-bug
reviewed/wontfix
skip-changelog
stale
status/blocked
status/needs-feedback
status/wip
theme/2fa
theme/authentication
theme/avatar
theme/backup-restore
theme/docker
theme/federation
theme/issues
theme/kanban
theme/markdown
theme/migration
theme/mobile
theme/pr
theme/signing
theme/sqlite
theme/timetracker
theme/webhook
theme/wiki
No Milestone
No project
No Assignees
2 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: lunny/gitea#8925
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix-8865"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #8865
NOTE: Props to @zeripath for devising a super-fast parsing function. ?
This makes it much faster for small unix files - but does slightly slow things down on big windows/mac files
Wow, that's fast
Is this faster then using something like
left = bytes.LastIndexByte(input, '\n') + 1
? My current system hasgccgo
so I'll check when I have a change to installgc
instead for a second.@ -66,0 +79,4 @@
pos += right
tmp[pos] = '\n'
left += right + 1
pos++
Nitpickest of nitpicks :)
@ -66,0 +79,4 @@
pos += right
tmp[pos] = '\n'
left += right + 1
pos++
It's not really different, since
len()
is not really a function but a language construct AFAIK. These are the numbers for 150,000 iterations (method9 is len before make):I've attached my tests four your reference.
@gary-kim check the test file attached in another comment; somehow I can't attach files inside code review comments.
@ -66,0 +79,4 @@
pos += right
tmp[pos] = '\n'
left += right + 1
pos++
@gary-kim Well, I stand corrected. I ran more tests and it seems it's slightly faster, go figure. Updated.
We can drop this check. We know that
input[left]
is not a\n
from line 76.In fact now that we have unfurled the initial step we can drop lines 76-84 and lines 86-89
And you can drop the
if left < length {
test at line 85 because the only way that could happen would causeright == -1
.So that code was munching initial
\n
to prevent them from being skipped. However, I've realised it's totally unnecessary, see below...See https://github.com/go-gitea/gitea/pull/8925#issuecomment-552804972
@ -66,0 +94,4 @@
}
copy(tmp[pos:pos+right], input[left:left+right])
pos += right
tmp[pos] = '\n'
In Java, the JVM JIT has a weird feature whereby it's actually quicker to assign names used inside loops rather than refer to things used outside the loops, e.g.
right := ...
would be quicker thanright = ...
. On testing, this does not appear to be the case for go's compiler.? @zeripath done.
This makes my eyes hurt but seems exponentially better than ones that don't sadly :)
Works fine on Mac.