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
67591c8c
Commit
67591c8c
authored
Aug 14, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sha1_lookup: do not use the "experimental" lookup mode
parent
2af9bcb2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
src/pack.c
+4
-1
src/sha1_lookup.c
+23
-1
src/sha1_lookup.h
+5
-0
No files found.
src/pack.c
View file @
67591c8c
...
...
@@ -1110,8 +1110,11 @@ static int pack_entry_find_offset(
short_oid
->
id
[
0
],
short_oid
->
id
[
1
],
short_oid
->
id
[
2
],
lo
,
hi
,
p
->
num_objects
);
#endif
/* Use git.git lookup code */
#ifdef GIT_USE_LOOKUP
pos
=
sha1_entry_pos
(
index
,
stride
,
0
,
lo
,
hi
,
p
->
num_objects
,
short_oid
->
id
);
#else
pos
=
sha1_position
(
index
,
stride
,
lo
,
hi
,
short_oid
->
id
);
#endif
if
(
pos
>=
0
)
{
/* An object matching exactly the oid was found */
...
...
src/sha1_lookup.c
View file @
67591c8c
...
...
@@ -9,6 +9,7 @@
#include "sha1_lookup.h"
#include "common.h"
#include "oid.h"
/*
* Conventional binary search loop looks like this:
...
...
@@ -123,7 +124,7 @@ int sha1_entry_pos(const void *table,
lov
=
(
lov
<<
8
)
|
lo_key
[
ofs_0
+
1
];
kyv
=
(
kyv
<<
8
)
|
key
[
ofs_0
+
1
];
}
assert
(
lov
<
hiv
);
assert
(
lov
<
=
hiv
);
if
(
kyv
<
lov
)
return
-
1
-
lo
;
...
...
@@ -176,3 +177,24 @@ int sha1_entry_pos(const void *table,
}
while
(
lo
<
hi
);
return
-
((
int
)
lo
)
-
1
;
}
int
sha1_position
(
const
void
*
table
,
size_t
stride
,
unsigned
lo
,
unsigned
hi
,
const
unsigned
char
*
key
)
{
do
{
unsigned
mi
=
(
lo
+
hi
)
/
2
;
int
cmp
=
git_oid__cmp
(
table
+
mi
*
stride
,
(
git_oid
*
)
key
);
if
(
!
cmp
)
return
mi
;
if
(
cmp
>
0
)
hi
=
mi
;
else
lo
=
mi
+
1
;
}
while
(
lo
<
hi
);
return
-
((
int
)
lo
)
-
1
;
}
src/sha1_lookup.h
View file @
67591c8c
...
...
@@ -15,4 +15,9 @@ int sha1_entry_pos(const void *table,
unsigned
lo
,
unsigned
hi
,
unsigned
nr
,
const
unsigned
char
*
key
);
int
sha1_position
(
const
void
*
table
,
size_t
stride
,
unsigned
lo
,
unsigned
hi
,
const
unsigned
char
*
key
);
#endif
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