Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
8242d2e0
Commit
8242d2e0
authored
Aug 14, 2007
by
Bradley C. Kuszmaul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unroll keycompare
git-svn-id:
file:///svn/tokudb@133
c7de825b-a66e-492c-adef-691d508d4ae1
parent
12c0bfee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
newbrt/key.c
newbrt/key.c
+25
-0
No files found.
newbrt/key.c
View file @
8242d2e0
...
@@ -46,12 +46,36 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
...
@@ -46,12 +46,36 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
else
return
-
1
;
else
return
-
1
;
}
}
}
}
#elif 0
/* This one looks tighter, but it does use memcmp... */
int
keycompare
(
bytevec
key1
,
ITEMLEN
key1len
,
bytevec
key2
,
ITEMLEN
key2len
)
{
int
comparelen
=
key1len
<
key2len
?
key1len
:
key2len
;
const
unsigned
char
*
k1
;
const
unsigned
char
*
k2
;
for
(
k1
=
key1
,
k2
=
key2
;
comparelen
>
0
;
k1
++
,
k2
++
,
comparelen
--
)
{
if
(
*
k1
!=
*
k2
)
{
return
(
int
)
*
k1
-
(
int
)
*
k2
;
}
}
return
key1len
-
key2len
;
}
#else
#else
/* unroll that one twice */
int
keycompare
(
bytevec
key1
,
ITEMLEN
key1len
,
bytevec
key2
,
ITEMLEN
key2len
)
{
int
keycompare
(
bytevec
key1
,
ITEMLEN
key1len
,
bytevec
key2
,
ITEMLEN
key2len
)
{
int
comparelen
=
key1len
<
key2len
?
key1len
:
key2len
;
int
comparelen
=
key1len
<
key2len
?
key1len
:
key2len
;
const
unsigned
char
*
k1
;
const
unsigned
char
*
k1
;
const
unsigned
char
*
k2
;
const
unsigned
char
*
k2
;
for
(
k1
=
key1
,
k2
=
key2
;
for
(
k1
=
key1
,
k2
=
key2
;
comparelen
>
4
;
k1
+=
4
,
k2
+=
4
,
comparelen
-=
4
)
{
{
int
v1
=
k1
[
0
],
v2
=
k2
[
0
];
if
(
v1
!=
v2
)
return
v1
-
v2
;
}
{
int
v1
=
k1
[
1
],
v2
=
k2
[
1
];
if
(
v1
!=
v2
)
return
v1
-
v2
;
}
{
int
v1
=
k1
[
2
],
v2
=
k2
[
2
];
if
(
v1
!=
v2
)
return
v1
-
v2
;
}
{
int
v1
=
k1
[
3
],
v2
=
k2
[
3
];
if
(
v1
!=
v2
)
return
v1
-
v2
;
}
}
for
(;
comparelen
>
0
;
comparelen
>
0
;
k1
++
,
k2
++
,
comparelen
--
)
{
k1
++
,
k2
++
,
comparelen
--
)
{
if
(
*
k1
!=
*
k2
)
{
if
(
*
k1
!=
*
k2
)
{
...
@@ -60,6 +84,7 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
...
@@ -60,6 +84,7 @@ int keycompare (bytevec key1, ITEMLEN key1len, bytevec key2, ITEMLEN key2len) {
}
}
return
key1len
-
key2len
;
return
key1len
-
key2len
;
}
}
#endif
#endif
void
test_keycompare
(
void
)
{
void
test_keycompare
(
void
)
{
...
...
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