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
50364dd8
Commit
50364dd8
authored
Jul 29, 2012
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #847 from schu/inline-oid-cmp
git_oid_cmp: inline memcmp by hand to optimize
parents
6810ba08
f6b26e77
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
include/git2/oid.h
+25
-1
src/oid.c
+0
-5
src/oidmap.h
+1
-6
No files found.
include/git2/oid.h
View file @
50364dd8
...
...
@@ -136,7 +136,31 @@ GIT_EXTERN(void) git_oid_cpy(git_oid *out, const git_oid *src);
* @param b second oid structure.
* @return <0, 0, >0 if a < b, a == b, a > b.
*/
GIT_EXTERN
(
int
)
git_oid_cmp
(
const
git_oid
*
a
,
const
git_oid
*
b
);
GIT_INLINE
(
int
)
git_oid_cmp
(
const
git_oid
*
a
,
const
git_oid
*
b
)
{
const
unsigned
char
*
sha1
=
a
->
id
;
const
unsigned
char
*
sha2
=
b
->
id
;
int
i
;
for
(
i
=
0
;
i
<
GIT_OID_RAWSZ
;
i
++
,
sha1
++
,
sha2
++
)
{
if
(
*
sha1
!=
*
sha2
)
return
*
sha1
-
*
sha2
;
}
return
0
;
}
/**
* Compare two oid structures for equality
*
* @param a first oid structure.
* @param b second oid structure.
* @return true if equal, false otherwise
*/
GIT_INLINE
(
int
)
git_oid_equal
(
const
git_oid
*
a
,
const
git_oid
*
b
)
{
return
!
git_oid_cmp
(
a
,
b
);
}
/**
* Compare the first 'len' hexadecimal characters (packets of 4 bits)
...
...
src/oid.c
View file @
50364dd8
...
...
@@ -161,11 +161,6 @@ void git_oid_cpy(git_oid *out, const git_oid *src)
memcpy
(
out
->
id
,
src
->
id
,
sizeof
(
out
->
id
));
}
int
git_oid_cmp
(
const
git_oid
*
a
,
const
git_oid
*
b
)
{
return
memcmp
(
a
->
id
,
b
->
id
,
sizeof
(
a
->
id
));
}
int
git_oid_ncmp
(
const
git_oid
*
oid_a
,
const
git_oid
*
oid_b
,
unsigned
int
len
)
{
const
unsigned
char
*
a
=
oid_a
->
id
;
...
...
src/oidmap.h
View file @
50364dd8
...
...
@@ -28,13 +28,8 @@ GIT_INLINE(khint_t) hash_git_oid(const git_oid *oid)
return
h
;
}
GIT_INLINE
(
int
)
hash_git_oid_equal
(
const
git_oid
*
a
,
const
git_oid
*
b
)
{
return
(
memcmp
(
a
->
id
,
b
->
id
,
sizeof
(
a
->
id
))
==
0
);
}
#define GIT__USE_OIDMAP \
__KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, hash_git_oid,
hash_
git_oid_equal)
__KHASH_IMPL(oid, static kh_inline, const git_oid *, void *, 1, hash_git_oid, git_oid_equal)
#define git_oidmap_alloc() kh_init(oid)
#define git_oidmap_free(h) kh_destroy(oid,h), h = NULL
...
...
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