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
a853c527
Commit
a853c527
authored
Jan 25, 2017
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
khash: avoid using `kh_get` directly
parent
64e46dc3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
src/cache.c
+2
-2
src/odb_mempack.c
+2
-2
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 @
a853c527
...
...
@@ -156,7 +156,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
if
(
!
git_cache__enabled
||
git_rwlock_rdlock
(
&
cache
->
lock
)
<
0
)
return
NULL
;
pos
=
kh_get
(
oid
,
cache
->
map
,
oid
);
pos
=
git_oidmap_lookup_index
(
cache
->
map
,
oid
);
if
(
git_oidmap_valid_index
(
cache
->
map
,
pos
))
{
entry
=
kh_val
(
cache
->
map
,
pos
);
...
...
@@ -193,7 +193,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
if
(
git_cache__current_storage
.
val
>
git_cache__max_storage
)
cache_evict_entries
(
cache
);
pos
=
kh_get
(
oid
,
cache
->
map
,
&
entry
->
oid
);
pos
=
git_oidmap_lookup_index
(
cache
->
map
,
&
entry
->
oid
);
/* not found */
if
(
!
git_oidmap_valid_index
(
cache
->
map
,
pos
))
{
...
...
src/odb_mempack.c
View file @
a853c527
...
...
@@ -82,7 +82,7 @@ static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb
struct
memobject
*
obj
=
NULL
;
khiter_t
pos
;
pos
=
kh_get
(
oid
,
db
->
objects
,
oid
);
pos
=
git_oidmap_lookup_index
(
db
->
objects
,
oid
);
if
(
!
git_oidmap_valid_index
(
db
->
objects
,
pos
))
return
GIT_ENOTFOUND
;
...
...
@@ -103,7 +103,7 @@ static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *
struct
memobject
*
obj
=
NULL
;
khiter_t
pos
;
pos
=
kh_get
(
oid
,
db
->
objects
,
oid
);
pos
=
git_oidmap_lookup_index
(
db
->
objects
,
oid
);
if
(
!
git_oidmap_valid_index
(
db
->
objects
,
pos
))
return
GIT_ENOTFOUND
;
...
...
src/pack-objects.c
View file @
a853c527
...
...
@@ -516,7 +516,7 @@ static int cb_tag_foreach(const char *name, git_oid *oid, void *data)
GIT_UNUSED
(
name
);
pos
=
kh_get
(
oid
,
pb
->
object_ix
,
oid
);
pos
=
git_oidmap_lookup_index
(
pb
->
object_ix
,
oid
);
if
(
!
git_oidmap_valid_index
(
pb
->
object_ix
,
pos
))
return
0
;
...
...
src/pack.c
View file @
a853c527
...
...
@@ -117,7 +117,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
if
(
git_mutex_lock
(
&
cache
->
lock
)
<
0
)
return
NULL
;
k
=
kh_get
(
off
,
cache
->
entries
,
offset
);
k
=
git_offmap_lookup_index
(
cache
->
entries
,
offset
);
if
(
git_offmap_valid_index
(
cache
->
entries
,
k
))
{
/* found it */
entry
=
kh_value
(
cache
->
entries
,
k
);
git_atomic_inc
(
&
entry
->
refcount
);
...
...
@@ -956,7 +956,7 @@ git_off_t get_delta_base(
git_oid
oid
;
git_oid_fromraw
(
&
oid
,
base_info
);
k
=
kh_get
(
oid
,
p
->
idx_cache
,
&
oid
);
k
=
git_oidmap_lookup_index
(
p
->
idx_cache
,
&
oid
);
if
(
git_oidmap_valid_index
(
p
->
idx_cache
,
k
))
{
*
curpos
+=
20
;
return
((
struct
git_pack_entry
*
)
kh_value
(
p
->
idx_cache
,
k
))
->
offset
;
...
...
src/revwalk.c
View file @
a853c527
...
...
@@ -25,7 +25,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
int
ret
;
/* lookup and reserve space if not already present */
pos
=
kh_get
(
oid
,
walk
->
commits
,
oid
);
pos
=
git_oidmap_lookup_index
(
walk
->
commits
,
oid
);
if
(
git_oidmap_valid_index
(
walk
->
commits
,
pos
))
return
kh_value
(
walk
->
commits
,
pos
);
...
...
tests/core/oidmap.c
View file @
a853c527
...
...
@@ -33,7 +33,7 @@ void test_core_oidmap__basic(void)
khiter_t
pos
;
int
ret
;
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
pos
=
git_oidmap_lookup_index
(
map
,
&
items
[
i
].
oid
);
cl_assert
(
!
git_oidmap_valid_index
(
map
,
pos
));
pos
=
kh_put
(
oid
,
map
,
&
items
[
i
].
oid
,
&
ret
);
...
...
@@ -46,7 +46,7 @@ void test_core_oidmap__basic(void)
for
(
i
=
0
;
i
<
NITEMS
;
++
i
)
{
khiter_t
pos
;
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
pos
=
git_oidmap_lookup_index
(
map
,
&
items
[
i
].
oid
);
cl_assert
(
git_oidmap_valid_index
(
map
,
pos
));
cl_assert_equal_p
(
kh_val
(
map
,
pos
),
&
items
[
i
]);
...
...
@@ -87,7 +87,7 @@ void test_core_oidmap__hash_collision(void)
khiter_t
pos
;
int
ret
;
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
pos
=
git_oidmap_lookup_index
(
map
,
&
items
[
i
].
oid
);
cl_assert
(
!
git_oidmap_valid_index
(
map
,
pos
));
pos
=
kh_put
(
oid
,
map
,
&
items
[
i
].
oid
,
&
ret
);
...
...
@@ -100,7 +100,7 @@ void test_core_oidmap__hash_collision(void)
for
(
i
=
0
;
i
<
NITEMS
;
++
i
)
{
khiter_t
pos
;
pos
=
kh_get
(
oid
,
map
,
&
items
[
i
].
oid
);
pos
=
git_oidmap_lookup_index
(
map
,
&
items
[
i
].
oid
);
cl_assert
(
git_oidmap_valid_index
(
map
,
pos
));
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