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
fcc60066
Commit
fcc60066
authored
Jun 09, 2014
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
treentry: no need for manual size book-keeping
We can simply ask the hasmap.
parent
978fbb4c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
10 deletions
+6
-10
src/tree.c
+6
-9
src/tree.h
+0
-1
No files found.
src/tree.c
View file @
fcc60066
...
...
@@ -367,7 +367,8 @@ size_t git_tree_entrycount(const git_tree *tree)
unsigned
int
git_treebuilder_entrycount
(
git_treebuilder
*
bld
)
{
assert
(
bld
);
return
(
unsigned
int
)
bld
->
entrycount
;
return
git_strmap_num_entries
(
bld
->
map
);
}
static
int
tree_error
(
const
char
*
str
,
const
char
*
path
)
...
...
@@ -469,7 +470,6 @@ static int append_entry(
return
-
1
;
}
bld
->
entrycount
++
;
return
0
;
}
...
...
@@ -680,7 +680,6 @@ int git_treebuilder_insert(
}
}
bld
->
entrycount
++
;
git_oid_cpy
(
&
entry
->
oid
,
id
);
entry
->
attr
=
filemode
;
...
...
@@ -719,14 +718,13 @@ int git_treebuilder_remove(git_treebuilder *bld, const char *filename)
git_strmap_delete
(
bld
->
map
,
filename
);
git_tree_entry_free
(
entry
);
bld
->
entrycount
--
;
return
0
;
}
int
git_treebuilder_write
(
git_oid
*
oid
,
git_repository
*
repo
,
git_treebuilder
*
bld
)
{
int
error
=
0
;
size_t
i
;
size_t
i
,
entrycount
;
git_buf
tree
=
GIT_BUF_INIT
;
git_odb
*
odb
;
git_tree_entry
*
entry
;
...
...
@@ -734,7 +732,8 @@ int git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *b
assert
(
bld
);
if
(
git_vector_init
(
&
entries
,
bld
->
entrycount
,
entry_sort_cmp
)
<
0
)
entrycount
=
git_strmap_num_entries
(
bld
->
map
);
if
(
git_vector_init
(
&
entries
,
entrycount
,
entry_sort_cmp
)
<
0
)
return
-
1
;
git_strmap_foreach_value
(
bld
->
map
,
entry
,
{
...
...
@@ -745,7 +744,7 @@ int git_treebuilder_write(git_oid *oid, git_repository *repo, git_treebuilder *b
git_vector_sort
(
&
entries
);
/* Grow the buffer beforehand to an estimated size */
error
=
git_buf_grow
(
&
tree
,
bld
->
entrycount
*
72
);
error
=
git_buf_grow
(
&
tree
,
entrycount
*
72
);
for
(
i
=
0
;
i
<
entries
.
length
&&
!
error
;
++
i
)
{
git_tree_entry
*
entry
=
git_vector_get
(
&
entries
,
i
);
...
...
@@ -781,7 +780,6 @@ void git_treebuilder_filter(
git_strmap_foreach
(
bld
->
map
,
filename
,
entry
,
{
if
(
filter
(
entry
,
payload
))
{
git_strmap_delete
(
bld
->
map
,
filename
);
bld
->
entrycount
--
;
git_tree_entry_free
(
entry
);
}
});
...
...
@@ -795,7 +793,6 @@ void git_treebuilder_clear(git_treebuilder *bld)
git_strmap_foreach_value
(
bld
->
map
,
e
,
git_tree_entry_free
(
e
));
git_strmap_clear
(
bld
->
map
);
bld
->
entrycount
=
0
;
}
void
git_treebuilder_free
(
git_treebuilder
*
bld
)
...
...
src/tree.h
View file @
fcc60066
...
...
@@ -26,7 +26,6 @@ struct git_tree {
};
struct
git_treebuilder
{
size_t
entrycount
;
/* vector may contain "removed" entries */
git_strmap
*
map
;
};
...
...
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