Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fzf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
fzf
Commits
0e0de29b
Unverified
Commit
0e0de29b
authored
8 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Inline function calls in tight loops
By only using leaf functions
parent
babf877f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/algo/algo.go
+3
-10
3 additions, 10 deletions
src/algo/algo.go
with
3 additions
and
10 deletions
src/algo/algo.go
+
3
−
10
View file @
0e0de29b
...
...
@@ -22,13 +22,6 @@ func indexAt(index int, max int, forward bool) int {
return
max
-
index
-
1
}
func
runeAt
(
text
util
.
Chars
,
index
int
,
max
int
,
forward
bool
)
rune
{
if
forward
{
return
text
.
Get
(
index
)
}
return
text
.
Get
(
max
-
index
-
1
)
}
// Result conatins the results of running a match function.
type
Result
struct
{
Start
int32
...
...
@@ -136,7 +129,7 @@ func FuzzyMatch(caseSensitive bool, forward bool, text util.Chars, pattern []run
lenPattern
:=
len
(
pattern
)
for
index
:=
0
;
index
<
lenRunes
;
index
++
{
char
:=
runeAt
(
text
,
index
,
lenRunes
,
forward
)
char
:=
text
.
Get
(
indexAt
(
index
,
lenRunes
,
forward
)
)
// This is considerably faster than blindly applying strings.ToLower to the
// whole string
if
!
caseSensitive
{
...
...
@@ -164,7 +157,7 @@ func FuzzyMatch(caseSensitive bool, forward bool, text util.Chars, pattern []run
if
sidx
>=
0
&&
eidx
>=
0
{
pidx
--
for
index
:=
eidx
-
1
;
index
>=
sidx
;
index
--
{
char
:=
runeAt
(
text
,
index
,
lenRunes
,
forward
)
char
:=
text
.
Get
(
indexAt
(
index
,
lenRunes
,
forward
)
)
if
!
caseSensitive
{
if
char
>=
'A'
&&
char
<=
'Z'
{
char
+=
32
...
...
@@ -215,7 +208,7 @@ func ExactMatchNaive(caseSensitive bool, forward bool, text util.Chars, pattern
pidx
:=
0
for
index
:=
0
;
index
<
lenRunes
;
index
++
{
char
:=
runeAt
(
text
,
index
,
lenRunes
,
forward
)
char
:=
text
.
Get
(
indexAt
(
index
,
lenRunes
,
forward
)
)
if
!
caseSensitive
{
if
char
>=
'A'
&&
char
<=
'Z'
{
char
+=
32
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment