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
4df53a64
Commit
4df53a64
authored
May 08, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2335 from libgit2/cmn/indexer-vector-handling
indexer: avoid memory moves
parents
5ebe18b7
2dde1e0c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
src/indexer.c
+15
-8
No files found.
src/indexer.c
View file @
4df53a64
...
...
@@ -717,6 +717,9 @@ static int fix_thin_pack(git_indexer *idx, git_transfer_progress *stats)
/* Loop until we find the first REF delta */
git_vector_foreach
(
&
idx
->
deltas
,
i
,
delta
)
{
if
(
!
delta
)
continue
;
curpos
=
delta
->
delta_off
;
error
=
git_packfile_unpack_header
(
&
size
,
&
type
,
&
idx
->
pack
->
mwf
,
&
w
,
&
curpos
);
git_mwindow_close
(
&
w
);
...
...
@@ -756,13 +759,18 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
{
unsigned
int
i
;
struct
delta_info
*
delta
;
int
progressed
=
0
,
progress_cb_result
;
int
progressed
=
0
,
non_null
=
0
,
progress_cb_result
;
while
(
idx
->
deltas
.
length
>
0
)
{
progressed
=
0
;
non_null
=
0
;
git_vector_foreach
(
&
idx
->
deltas
,
i
,
delta
)
{
git_rawobj
obj
;
if
(
!
delta
)
continue
;
non_null
=
1
;
idx
->
off
=
delta
->
delta_off
;
if
(
git_packfile_unpack
(
&
obj
,
idx
->
pack
,
&
idx
->
off
)
<
0
)
continue
;
...
...
@@ -777,16 +785,15 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats)
if
((
progress_cb_result
=
do_progress_callback
(
idx
,
stats
))
<
0
)
return
progress_cb_result
;
/*
* Remove this delta from the list and
* decrease i so we don't skip over the next
* delta.
*/
git_vector_remove
(
&
idx
->
deltas
,
i
);
/* remove from the list */
git_vector_set
(
NULL
,
&
idx
->
deltas
,
i
,
NULL
);
git__free
(
delta
);
i
--
;
}
/* if none were actually set, we're done */
if
(
!
non_null
)
break
;
if
(
!
progressed
&&
(
fix_thin_pack
(
idx
,
stats
)
<
0
))
{
giterr_set
(
GITERR_INDEXER
,
"missing delta bases"
);
return
-
1
;
...
...
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