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
9694d9ba
Commit
9694d9ba
authored
Jan 25, 2017
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
khash: avoid using `kh_foreach`/`kh_foreach_value` directly
parent
63e914cb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
32 deletions
+17
-32
src/cache.c
+2
-2
src/indexer.c
+3
-2
src/odb_mempack.c
+1
-1
src/pack.c
+6
-12
src/revwalk.c
+1
-1
src/transaction.c
+4
-14
No files found.
src/cache.c
View file @
9694d9ba
...
@@ -53,7 +53,7 @@ void git_cache_dump_stats(git_cache *cache)
...
@@ -53,7 +53,7 @@ void git_cache_dump_stats(git_cache *cache)
printf
(
"Cache %p: %"
PRIuZ
" items cached, %"
PRIdZ
" bytes
\n
"
,
printf
(
"Cache %p: %"
PRIuZ
" items cached, %"
PRIdZ
" bytes
\n
"
,
cache
,
git_cache_size
(
cache
),
cache
->
used_memory
);
cache
,
git_cache_size
(
cache
),
cache
->
used_memory
);
kh
_foreach_value
(
cache
->
map
,
object
,
{
git_oidmap
_foreach_value
(
cache
->
map
,
object
,
{
char
oid_str
[
9
];
char
oid_str
[
9
];
printf
(
" %s%c %s (%"
PRIuZ
")
\n
"
,
printf
(
" %s%c %s (%"
PRIuZ
")
\n
"
,
git_object_type2string
(
object
->
type
),
git_object_type2string
(
object
->
type
),
...
@@ -84,7 +84,7 @@ static void clear_cache(git_cache *cache)
...
@@ -84,7 +84,7 @@ static void clear_cache(git_cache *cache)
if
(
git_cache_size
(
cache
)
==
0
)
if
(
git_cache_size
(
cache
)
==
0
)
return
;
return
;
kh
_foreach_value
(
cache
->
map
,
evict
,
{
git_oidmap
_foreach_value
(
cache
->
map
,
evict
,
{
git_cached_obj_decref
(
evict
);
git_cached_obj_decref
(
evict
);
});
});
...
...
src/indexer.c
View file @
9694d9ba
...
@@ -1106,8 +1106,9 @@ void git_indexer_free(git_indexer *idx)
...
@@ -1106,8 +1106,9 @@ void git_indexer_free(git_indexer *idx)
if
(
idx
->
pack
->
idx_cache
)
{
if
(
idx
->
pack
->
idx_cache
)
{
struct
git_pack_entry
*
pentry
;
struct
git_pack_entry
*
pentry
;
kh_foreach_value
(
git_oidmap_foreach_value
(
idx
->
pack
->
idx_cache
,
pentry
,
{
idx
->
pack
->
idx_cache
,
pentry
,
{
git__free
(
pentry
);
});
git__free
(
pentry
);
});
git_oidmap_free
(
idx
->
pack
->
idx_cache
);
git_oidmap_free
(
idx
->
pack
->
idx_cache
);
}
}
...
...
src/odb_mempack.c
View file @
9694d9ba
...
@@ -149,7 +149,7 @@ void git_mempack_reset(git_odb_backend *_backend)
...
@@ -149,7 +149,7 @@ void git_mempack_reset(git_odb_backend *_backend)
struct
memory_packer_db
*
db
=
(
struct
memory_packer_db
*
)
_backend
;
struct
memory_packer_db
*
db
=
(
struct
memory_packer_db
*
)
_backend
;
struct
memobject
*
object
=
NULL
;
struct
memobject
*
object
=
NULL
;
kh
_foreach_value
(
db
->
objects
,
object
,
{
git_oidmap
_foreach_value
(
db
->
objects
,
object
,
{
git__free
(
object
);
git__free
(
object
);
});
});
...
...
src/pack.c
View file @
9694d9ba
...
@@ -78,13 +78,12 @@ static void free_cache_object(void *o)
...
@@ -78,13 +78,12 @@ static void free_cache_object(void *o)
static
void
cache_free
(
git_pack_cache
*
cache
)
static
void
cache_free
(
git_pack_cache
*
cache
)
{
{
khiter_t
k
;
git_pack_cache_entry
*
entry
;
if
(
cache
->
entries
)
{
if
(
cache
->
entries
)
{
for
(
k
=
kh_begin
(
cache
->
entries
);
k
!=
kh_end
(
cache
->
entries
);
k
++
)
{
git_offmap_foreach_value
(
cache
->
entries
,
entry
,
{
if
(
kh_exist
(
cache
->
entries
,
k
))
free_cache_object
(
entry
);
free_cache_object
(
kh_value
(
cache
->
entries
,
k
));
});
}
git_offmap_free
(
cache
->
entries
);
git_offmap_free
(
cache
->
entries
);
cache
->
entries
=
NULL
;
cache
->
entries
=
NULL
;
...
@@ -135,18 +134,13 @@ static void free_lowest_entry(git_pack_cache *cache)
...
@@ -135,18 +134,13 @@ static void free_lowest_entry(git_pack_cache *cache)
git_pack_cache_entry
*
entry
;
git_pack_cache_entry
*
entry
;
khiter_t
k
;
khiter_t
k
;
for
(
k
=
kh_begin
(
cache
->
entries
);
k
!=
kh_end
(
cache
->
entries
);
k
++
)
{
git_offmap_foreach
(
cache
->
entries
,
k
,
entry
,
{
if
(
!
kh_exist
(
cache
->
entries
,
k
))
continue
;
entry
=
kh_value
(
cache
->
entries
,
k
);
if
(
entry
&&
entry
->
refcount
.
val
==
0
)
{
if
(
entry
&&
entry
->
refcount
.
val
==
0
)
{
cache
->
memory_used
-=
entry
->
raw
.
len
;
cache
->
memory_used
-=
entry
->
raw
.
len
;
kh_del
(
off
,
cache
->
entries
,
k
);
kh_del
(
off
,
cache
->
entries
,
k
);
free_cache_object
(
entry
);
free_cache_object
(
entry
);
}
}
}
}
);
}
}
static
int
cache_add
(
static
int
cache_add
(
...
...
src/revwalk.c
View file @
9694d9ba
...
@@ -702,7 +702,7 @@ void git_revwalk_reset(git_revwalk *walk)
...
@@ -702,7 +702,7 @@ void git_revwalk_reset(git_revwalk *walk)
assert
(
walk
);
assert
(
walk
);
kh
_foreach_value
(
walk
->
commits
,
commit
,
{
git_oidmap
_foreach_value
(
walk
->
commits
,
commit
,
{
commit
->
seen
=
0
;
commit
->
seen
=
0
;
commit
->
in_degree
=
0
;
commit
->
in_degree
=
0
;
commit
->
topo_delay
=
0
;
commit
->
topo_delay
=
0
;
...
...
src/transaction.c
View file @
9694d9ba
...
@@ -323,7 +323,6 @@ static int update_target(git_refdb *db, transaction_node *node)
...
@@ -323,7 +323,6 @@ static int update_target(git_refdb *db, transaction_node *node)
int
git_transaction_commit
(
git_transaction
*
tx
)
int
git_transaction_commit
(
git_transaction
*
tx
)
{
{
transaction_node
*
node
;
transaction_node
*
node
;
git_strmap_iter
pos
;
int
error
=
0
;
int
error
=
0
;
assert
(
tx
);
assert
(
tx
);
...
@@ -335,11 +334,7 @@ int git_transaction_commit(git_transaction *tx)
...
@@ -335,11 +334,7 @@ int git_transaction_commit(git_transaction *tx)
return
error
;
return
error
;
}
}
for
(
pos
=
kh_begin
(
tx
->
locks
);
pos
<
kh_end
(
tx
->
locks
);
pos
++
)
{
git_strmap_foreach_value
(
tx
->
locks
,
node
,
{
if
(
!
git_strmap_has_data
(
tx
->
locks
,
pos
))
continue
;
node
=
git_strmap_value_at
(
tx
->
locks
,
pos
);
if
(
node
->
reflog
)
{
if
(
node
->
reflog
)
{
if
((
error
=
tx
->
db
->
backend
->
reflog_write
(
tx
->
db
->
backend
,
node
->
reflog
))
<
0
)
if
((
error
=
tx
->
db
->
backend
->
reflog_write
(
tx
->
db
->
backend
,
node
->
reflog
))
<
0
)
return
error
;
return
error
;
...
@@ -349,7 +344,7 @@ int git_transaction_commit(git_transaction *tx)
...
@@ -349,7 +344,7 @@ int git_transaction_commit(git_transaction *tx)
if
((
error
=
update_target
(
tx
->
db
,
node
))
<
0
)
if
((
error
=
update_target
(
tx
->
db
,
node
))
<
0
)
return
error
;
return
error
;
}
}
}
}
);
return
0
;
return
0
;
}
}
...
@@ -358,7 +353,6 @@ void git_transaction_free(git_transaction *tx)
...
@@ -358,7 +353,6 @@ void git_transaction_free(git_transaction *tx)
{
{
transaction_node
*
node
;
transaction_node
*
node
;
git_pool
pool
;
git_pool
pool
;
git_strmap_iter
pos
;
assert
(
tx
);
assert
(
tx
);
...
@@ -373,16 +367,12 @@ void git_transaction_free(git_transaction *tx)
...
@@ -373,16 +367,12 @@ void git_transaction_free(git_transaction *tx)
}
}
/* start by unlocking the ones we've left hanging, if any */
/* start by unlocking the ones we've left hanging, if any */
for
(
pos
=
kh_begin
(
tx
->
locks
);
pos
<
kh_end
(
tx
->
locks
);
pos
++
)
{
git_strmap_foreach_value
(
tx
->
locks
,
node
,
{
if
(
!
git_strmap_has_data
(
tx
->
locks
,
pos
))
continue
;
node
=
git_strmap_value_at
(
tx
->
locks
,
pos
);
if
(
node
->
committed
)
if
(
node
->
committed
)
continue
;
continue
;
git_refdb_unlock
(
tx
->
db
,
node
->
payload
,
false
,
false
,
NULL
,
NULL
,
NULL
);
git_refdb_unlock
(
tx
->
db
,
node
->
payload
,
false
,
false
,
NULL
,
NULL
,
NULL
);
}
}
);
git_refdb_free
(
tx
->
db
);
git_refdb_free
(
tx
->
db
);
git_strmap_free
(
tx
->
locks
);
git_strmap_free
(
tx
->
locks
);
...
...
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