Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
d7d46cfb
Commit
d7d46cfb
authored
9 years ago
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
index: Preallocate the entries vector with size hint
parent
0cc20a8c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
src/index.c
+8
-0
src/vector.c
+7
-0
src/vector.h
+1
-0
No files found.
src/index.c
View file @
d7d46cfb
...
...
@@ -1556,11 +1556,19 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
assert
(
index
);
if
(
!
source_entries
->
length
)
return
0
;
if
(
git_mutex_lock
(
&
index
->
lock
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"Unable to acquire index lock"
);
return
-
1
;
}
if
(
git_vector_size_hint
(
&
index
->
entries
,
source_entries
->
length
)
<
0
)
{
git_mutex_unlock
(
&
index
->
lock
);
return
-
1
;
}
git_vector_foreach
(
source_entries
,
i
,
source_entry
)
{
git_index_entry
*
entry
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
src/vector.c
View file @
d7d46cfb
...
...
@@ -40,6 +40,13 @@ GIT_INLINE(int) resize_vector(git_vector *v, size_t new_size)
return
0
;
}
int
git_vector_size_hint
(
git_vector
*
v
,
size_t
size_hint
)
{
if
(
v
->
_alloc_size
>=
size_hint
)
return
0
;
return
resize_vector
(
v
,
size_hint
);
}
int
git_vector_dup
(
git_vector
*
v
,
const
git_vector
*
src
,
git_vector_cmp
cmp
)
{
size_t
bytes
;
...
...
This diff is collapsed.
Click to expand it.
src/vector.h
View file @
d7d46cfb
...
...
@@ -32,6 +32,7 @@ void git_vector_free_deep(git_vector *v); /* free each entry and self */
void
git_vector_clear
(
git_vector
*
v
);
int
git_vector_dup
(
git_vector
*
v
,
const
git_vector
*
src
,
git_vector_cmp
cmp
);
void
git_vector_swap
(
git_vector
*
a
,
git_vector
*
b
);
int
git_vector_size_hint
(
git_vector
*
v
,
size_t
size_hint
);
void
**
git_vector_detach
(
size_t
*
size
,
size_t
*
asize
,
git_vector
*
v
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment