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
d94dfe08
Commit
d94dfe08
authored
10 years ago
by
Junegunn Choi
Browse files
Options
Downloads
Patches
Plain Diff
Fix #151 - reduce initial memory footprint
parent
61300267
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/matcher.go
+4
-0
4 additions, 0 deletions
src/matcher.go
src/merger.go
+23
-1
23 additions, 1 deletion
src/merger.go
with
27 additions
and
1 deletion
src/matcher.go
+
4
−
0
View file @
d94dfe08
...
...
@@ -134,6 +134,10 @@ func (m *Matcher) scan(request MatchRequest) (*Merger, bool) {
}
pattern
:=
request
.
pattern
empty
:=
pattern
.
IsEmpty
()
if
empty
{
return
PassMerger
(
&
request
.
chunks
,
m
.
tac
),
false
}
cancelled
:=
util
.
NewAtomicBool
(
false
)
slices
:=
m
.
sliceChunks
(
request
.
chunks
)
...
...
This diff is collapsed.
Click to expand it.
src/merger.go
+
23
−
1
View file @
d94dfe08
...
...
@@ -10,6 +10,7 @@ var EmptyMerger = NewMerger([][]*Item{}, false, false)
type
Merger
struct
{
lists
[][]
*
Item
merged
[]
*
Item
chunks
*
[]
*
Chunk
cursors
[]
int
sorted
bool
tac
bool
...
...
@@ -17,11 +18,24 @@ type Merger struct {
count
int
}
func
PassMerger
(
chunks
*
[]
*
Chunk
,
tac
bool
)
*
Merger
{
mg
:=
Merger
{
chunks
:
chunks
,
tac
:
tac
,
count
:
0
}
for
_
,
chunk
:=
range
*
mg
.
chunks
{
mg
.
count
+=
len
(
*
chunk
)
}
return
&
mg
}
// NewMerger returns a new Merger
func
NewMerger
(
lists
[][]
*
Item
,
sorted
bool
,
tac
bool
)
*
Merger
{
mg
:=
Merger
{
lists
:
lists
,
merged
:
[]
*
Item
{},
chunks
:
nil
,
cursors
:
make
([]
int
,
len
(
lists
)),
sorted
:
sorted
,
tac
:
tac
,
...
...
@@ -41,12 +55,20 @@ func (mg *Merger) Length() int {
// Get returns the pointer to the Item object indexed by the given integer
func
(
mg
*
Merger
)
Get
(
idx
int
)
*
Item
{
if
mg
.
chunks
!=
nil
{
if
mg
.
tac
{
idx
=
mg
.
count
-
idx
-
1
}
chunk
:=
(
*
mg
.
chunks
)[
idx
/
ChunkSize
]
return
(
*
chunk
)[
idx
%
ChunkSize
]
}
if
mg
.
sorted
{
return
mg
.
mergedGet
(
idx
)
}
if
mg
.
tac
{
idx
=
mg
.
Length
()
-
idx
-
1
idx
=
mg
.
count
-
idx
-
1
}
for
_
,
list
:=
range
mg
.
lists
{
numItems
:=
len
(
list
)
...
...
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