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
6b90e244
Commit
6b90e244
authored
Apr 01, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Per-object filtering
parent
5df18424
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
src/cache.c
+31
-6
src/cache.h
+2
-1
No files found.
src/cache.c
View file @
6b90e244
...
...
@@ -17,8 +17,22 @@
GIT__USE_OIDMAP
bool
git_cache__store_types
[
8
]
=
{
false
,
/* GIT_OBJ__EXT1 */
true
,
/* GIT_OBJ_COMMIT */
true
,
/* GIT_OBJ_TREE */
false
,
/* GIT_OBJ_BLOB */
true
,
/* GIT_OBJ_TAG */
false
,
/* GIT_OBJ__EXT2 */
false
,
/* GIT_OBJ_OFS_DELTA */
false
/* GIT_OBJ_REF_DELTA */
};
size_t
git_cache__max_object_size
=
4096
;
int
git_cache_init
(
git_cache
*
cache
)
{
cache
->
lru_count
=
0
;
cache
->
map
=
git_oidmap_alloc
();
git_mutex_init
(
&
cache
->
lock
);
return
0
;
...
...
@@ -30,8 +44,14 @@ void git_cache_free(git_cache *cache)
git_mutex_free
(
&
cache
->
lock
);
}
static
bool
cache_should_store
(
git_
cached_obj
*
entry
)
static
bool
cache_should_store
(
git_
otype
object_type
,
size_t
object_size
)
{
if
(
!
git_cache__store_types
[
object_type
])
return
false
;
if
(
object_size
>
git_cache__max_object_size
)
return
false
;
return
true
;
}
...
...
@@ -63,11 +83,6 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
{
khiter_t
pos
;
git_cached_obj_incref
(
entry
);
if
(
!
cache_should_store
(
entry
))
return
entry
;
if
(
git_mutex_lock
(
&
cache
->
lock
)
<
0
)
return
entry
;
...
...
@@ -110,12 +125,22 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
void
*
git_cache_store_raw
(
git_cache
*
cache
,
git_odb_object
*
entry
)
{
git_cached_obj_incref
(
entry
);
if
(
!
cache_should_store
(
entry
->
raw
.
type
,
entry
->
raw
.
len
))
return
entry
;
entry
->
cached
.
flags
=
GIT_CACHE_STORE_RAW
;
return
cache_store
(
cache
,
(
git_cached_obj
*
)
entry
);
}
void
*
git_cache_store_parsed
(
git_cache
*
cache
,
git_object
*
entry
)
{
git_cached_obj_incref
(
entry
);
if
(
!
cache_should_store
(
entry
->
type
,
0
/* TODO */
))
return
entry
;
entry
->
cached
.
flags
=
GIT_CACHE_STORE_PARSED
;
return
cache_store
(
cache
,
(
git_cached_obj
*
)
entry
);
}
...
...
src/cache.h
View file @
6b90e244
...
...
@@ -23,7 +23,8 @@ enum {
typedef
struct
{
git_oid
oid
;
git_atomic
refcount
;
uint32_t
flags
;
uint16_t
flags
;
uint16_t
lru
;
}
git_cached_obj
;
typedef
struct
{
...
...
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