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
64e46dc3
Commit
64e46dc3
authored
Jan 25, 2017
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
khash: avoid using `kh_end` directly
parent
036daa59
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
13 deletions
+16
-13
src/cache.c
+3
-3
src/odb_mempack.c
+2
-2
src/oidmap.h
+3
-0
src/pack-objects.c
+1
-1
src/pack.c
+2
-2
src/revwalk.c
+1
-1
tests/core/oidmap.c
+4
-4
No files found.
src/cache.c
View file @
64e46dc3
...
@@ -125,7 +125,7 @@ static void cache_evict_entries(git_cache *cache)
...
@@ -125,7 +125,7 @@ static void cache_evict_entries(git_cache *cache)
}
}
while
(
evict_count
>
0
)
{
while
(
evict_count
>
0
)
{
khiter_t
pos
=
seed
++
%
kh
_end
(
cache
->
map
);
khiter_t
pos
=
seed
++
%
git_oidmap
_end
(
cache
->
map
);
if
(
kh_exist
(
cache
->
map
,
pos
))
{
if
(
kh_exist
(
cache
->
map
,
pos
))
{
git_cached_obj
*
evict
=
kh_val
(
cache
->
map
,
pos
);
git_cached_obj
*
evict
=
kh_val
(
cache
->
map
,
pos
);
...
@@ -157,7 +157,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
...
@@ -157,7 +157,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
return
NULL
;
return
NULL
;
pos
=
kh_get
(
oid
,
cache
->
map
,
oid
);
pos
=
kh_get
(
oid
,
cache
->
map
,
oid
);
if
(
pos
!=
kh_end
(
cache
->
map
))
{
if
(
git_oidmap_valid_index
(
cache
->
map
,
pos
))
{
entry
=
kh_val
(
cache
->
map
,
pos
);
entry
=
kh_val
(
cache
->
map
,
pos
);
if
(
flags
&&
entry
->
flags
!=
flags
)
{
if
(
flags
&&
entry
->
flags
!=
flags
)
{
...
@@ -196,7 +196,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
...
@@ -196,7 +196,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
pos
=
kh_get
(
oid
,
cache
->
map
,
&
entry
->
oid
);
pos
=
kh_get
(
oid
,
cache
->
map
,
&
entry
->
oid
);
/* not found */
/* not found */
if
(
pos
==
kh_end
(
cache
->
map
))
{
if
(
!
git_oidmap_valid_index
(
cache
->
map
,
pos
))
{
int
rval
;
int
rval
;
pos
=
kh_put
(
oid
,
cache
->
map
,
&
entry
->
oid
,
&
rval
);
pos
=
kh_put
(
oid
,
cache
->
map
,
&
entry
->
oid
,
&
rval
);
...
...
src/odb_mempack.c
View file @
64e46dc3
...
@@ -83,7 +83,7 @@ static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb
...
@@ -83,7 +83,7 @@ static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb
khiter_t
pos
;
khiter_t
pos
;
pos
=
kh_get
(
oid
,
db
->
objects
,
oid
);
pos
=
kh_get
(
oid
,
db
->
objects
,
oid
);
if
(
pos
==
kh_end
(
db
->
object
s
))
if
(
!
git_oidmap_valid_index
(
db
->
objects
,
po
s
))
return
GIT_ENOTFOUND
;
return
GIT_ENOTFOUND
;
obj
=
kh_val
(
db
->
objects
,
pos
);
obj
=
kh_val
(
db
->
objects
,
pos
);
...
@@ -104,7 +104,7 @@ static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *
...
@@ -104,7 +104,7 @@ static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *
khiter_t
pos
;
khiter_t
pos
;
pos
=
kh_get
(
oid
,
db
->
objects
,
oid
);
pos
=
kh_get
(
oid
,
db
->
objects
,
oid
);
if
(
pos
==
kh_end
(
db
->
object
s
))
if
(
!
git_oidmap_valid_index
(
db
->
objects
,
po
s
))
return
GIT_ENOTFOUND
;
return
GIT_ENOTFOUND
;
obj
=
kh_val
(
db
->
objects
,
pos
);
obj
=
kh_val
(
db
->
objects
,
pos
);
...
...
src/oidmap.h
View file @
64e46dc3
...
@@ -49,6 +49,9 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
...
@@ -49,6 +49,9 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
#define git_oidmap_foreach_value kh_foreach_value
#define git_oidmap_foreach_value kh_foreach_value
#define git_oidmap_begin kh_begin
#define git_oidmap_end kh_end
#define git_oidmap_size(h) kh_size(h)
#define git_oidmap_size(h) kh_size(h)
#define git_oidmap_clear(h) kh_clear(oid, h)
#define git_oidmap_clear(h) kh_clear(oid, h)
...
...
src/pack-objects.c
View file @
64e46dc3
...
@@ -517,7 +517,7 @@ static int cb_tag_foreach(const char *name, git_oid *oid, void *data)
...
@@ -517,7 +517,7 @@ static int cb_tag_foreach(const char *name, git_oid *oid, void *data)
GIT_UNUSED
(
name
);
GIT_UNUSED
(
name
);
pos
=
kh_get
(
oid
,
pb
->
object_ix
,
oid
);
pos
=
kh_get
(
oid
,
pb
->
object_ix
,
oid
);
if
(
pos
==
kh_end
(
pb
->
object_ix
))
if
(
!
git_oidmap_valid_index
(
pb
->
object_ix
,
pos
))
return
0
;
return
0
;
po
=
kh_value
(
pb
->
object_ix
,
pos
);
po
=
kh_value
(
pb
->
object_ix
,
pos
);
...
...
src/pack.c
View file @
64e46dc3
...
@@ -118,7 +118,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
...
@@ -118,7 +118,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
return
NULL
;
return
NULL
;
k
=
kh_get
(
off
,
cache
->
entries
,
offset
);
k
=
kh_get
(
off
,
cache
->
entries
,
offset
);
if
(
k
!=
kh_end
(
cache
->
entries
))
{
/* found it */
if
(
git_offmap_valid_index
(
cache
->
entries
,
k
))
{
/* found it */
entry
=
kh_value
(
cache
->
entries
,
k
);
entry
=
kh_value
(
cache
->
entries
,
k
);
git_atomic_inc
(
&
entry
->
refcount
);
git_atomic_inc
(
&
entry
->
refcount
);
entry
->
last_usage
=
cache
->
use_ctr
++
;
entry
->
last_usage
=
cache
->
use_ctr
++
;
...
@@ -957,7 +957,7 @@ git_off_t get_delta_base(
...
@@ -957,7 +957,7 @@ git_off_t get_delta_base(
git_oid_fromraw
(
&
oid
,
base_info
);
git_oid_fromraw
(
&
oid
,
base_info
);
k
=
kh_get
(
oid
,
p
->
idx_cache
,
&
oid
);
k
=
kh_get
(
oid
,
p
->
idx_cache
,
&
oid
);
if
(
k
!=
kh_end
(
p
->
idx_cache
))
{
if
(
git_oidmap_valid_index
(
p
->
idx_cache
,
k
))
{
*
curpos
+=
20
;
*
curpos
+=
20
;
return
((
struct
git_pack_entry
*
)
kh_value
(
p
->
idx_cache
,
k
))
->
offset
;
return
((
struct
git_pack_entry
*
)
kh_value
(
p
->
idx_cache
,
k
))
->
offset
;
}
else
{
}
else
{
...
...
src/revwalk.c
View file @
64e46dc3
...
@@ -26,7 +26,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
...
@@ -26,7 +26,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
/* lookup and reserve space if not already present */
/* lookup and reserve space if not already present */
pos
=
kh_get
(
oid
,
walk
->
commits
,
oid
);
pos
=
kh_get
(
oid
,
walk
->
commits
,
oid
);
if
(
pos
!=
kh_end
(
walk
->
commit
s
))
if
(
git_oidmap_valid_index
(
walk
->
commits
,
po
s
))
return
kh_value
(
walk
->
commits
,
pos
);
return
kh_value
(
walk
->
commits
,
pos
);
commit
=
git_commit_list_alloc_node
(
walk
);
commit
=
git_commit_list_alloc_node
(
walk
);
...
...
tests/core/oidmap.c
View file @
64e46dc3
...
@@ -34,7 +34,7 @@ void test_core_oidmap__basic(void)
...
@@ -34,7 +34,7 @@ void test_core_oidmap__basic(void)
int
ret
;
int
ret
;
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
cl_assert
(
pos
==
kh_end
(
map
));
cl_assert
(
!
git_oidmap_valid_index
(
map
,
pos
));
pos
=
kh_put
(
oid
,
map
,
&
items
[
i
].
oid
,
&
ret
);
pos
=
kh_put
(
oid
,
map
,
&
items
[
i
].
oid
,
&
ret
);
cl_assert
(
ret
!=
0
);
cl_assert
(
ret
!=
0
);
...
@@ -47,7 +47,7 @@ void test_core_oidmap__basic(void)
...
@@ -47,7 +47,7 @@ void test_core_oidmap__basic(void)
khiter_t
pos
;
khiter_t
pos
;
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
cl_assert
(
pos
!=
kh_end
(
map
));
cl_assert
(
git_oidmap_valid_index
(
map
,
pos
));
cl_assert_equal_p
(
kh_val
(
map
,
pos
),
&
items
[
i
]);
cl_assert_equal_p
(
kh_val
(
map
,
pos
),
&
items
[
i
]);
}
}
...
@@ -88,7 +88,7 @@ void test_core_oidmap__hash_collision(void)
...
@@ -88,7 +88,7 @@ void test_core_oidmap__hash_collision(void)
int
ret
;
int
ret
;
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
cl_assert
(
pos
==
kh_end
(
map
));
cl_assert
(
!
git_oidmap_valid_index
(
map
,
pos
));
pos
=
kh_put
(
oid
,
map
,
&
items
[
i
].
oid
,
&
ret
);
pos
=
kh_put
(
oid
,
map
,
&
items
[
i
].
oid
,
&
ret
);
cl_assert
(
ret
!=
0
);
cl_assert
(
ret
!=
0
);
...
@@ -101,7 +101,7 @@ void test_core_oidmap__hash_collision(void)
...
@@ -101,7 +101,7 @@ void test_core_oidmap__hash_collision(void)
khiter_t
pos
;
khiter_t
pos
;
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
cl_assert
(
pos
!=
kh_end
(
map
));
cl_assert
(
git_oidmap_valid_index
(
map
,
pos
));
cl_assert_equal_p
(
kh_val
(
map
,
pos
),
&
items
[
i
]);
cl_assert_equal_p
(
kh_val
(
map
,
pos
),
&
items
[
i
]);
}
}
...
...
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