Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
d5a0334b
Commit
d5a0334b
authored
Apr 19, 2022
by
Jan Sikorski
Committed by
Alexandre Julliard
Apr 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Faster memcmp().
Signed-off-by:
Jan Sikorski
<
jsikorski@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
68b6e876
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
6 deletions
+49
-6
string.c
dlls/msvcrt/string.c
+49
-6
No files found.
dlls/msvcrt/string.c
View file @
d5a0334b
...
...
@@ -2675,21 +2675,64 @@ int CDECL I10_OUTPUT(MSVCRT__LDOUBLE ld80, int prec, int flag, struct _I10_OUTPU
}
#undef I10_OUTPUT_MAX_PREC
/*********************************************************************
* memcmp (MSVCRT.@)
*/
int
__cdecl
memcmp
(
const
void
*
ptr1
,
const
void
*
ptr2
,
size_t
n
)
static
inline
int
memcmp_bytes
(
const
void
*
ptr1
,
const
void
*
ptr2
,
size_t
n
)
{
const
unsigned
char
*
p1
,
*
p2
;
for
(
p1
=
ptr1
,
p2
=
ptr2
;
n
;
n
--
,
p1
++
,
p2
++
)
{
if
(
*
p1
<
*
p2
)
return
-
1
;
if
(
*
p1
>
*
p2
)
return
1
;
if
(
*
p1
!=
*
p2
)
return
*
p1
>
*
p2
?
1
:
-
1
;
}
return
0
;
}
static
inline
int
memcmp_blocks
(
const
void
*
ptr1
,
const
void
*
ptr2
,
size_t
size
)
{
typedef
uint64_t
DECLSPEC_ALIGN
(
1
)
unaligned_ui64
;
const
uint64_t
*
p1
=
ptr1
;
const
unaligned_ui64
*
p2
=
ptr2
;
size_t
remainder
=
size
&
(
sizeof
(
uint64_t
)
-
1
);
size_t
block_count
=
size
/
sizeof
(
uint64_t
);
while
(
block_count
)
{
if
(
*
p1
!=
*
p2
)
return
memcmp_bytes
(
p1
,
p2
,
sizeof
(
uint64_t
));
p1
++
;
p2
++
;
block_count
--
;
}
return
memcmp_bytes
(
p1
,
p2
,
remainder
);
}
/*********************************************************************
* memcmp (MSVCRT.@)
*/
int
__cdecl
memcmp
(
const
void
*
ptr1
,
const
void
*
ptr2
,
size_t
n
)
{
const
unsigned
char
*
p1
=
ptr1
,
*
p2
=
ptr2
;
size_t
align
;
int
result
;
if
(
n
<
sizeof
(
uint64_t
))
return
memcmp_bytes
(
p1
,
p2
,
n
);
align
=
-
(
size_t
)
p1
&
(
sizeof
(
uint64_t
)
-
1
);
if
((
result
=
memcmp_bytes
(
p1
,
p2
,
align
)))
return
result
;
p1
+=
align
;
p2
+=
align
;
n
-=
align
;
return
memcmp_blocks
(
p1
,
p2
,
n
);
}
#if defined(__i386__) || defined(__x86_64__)
#ifdef __i386__
...
...
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