Piotr Caban : msvcrt: Optimize _strupr implementation in C locale.
Alexandre Julliard
julliard at winehq.org
Thu Mar 22 17:08:16 CDT 2018
Module: wine
Branch: master
Commit: 52415cabb078bac172d21c1a41dc81520eeca1f1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=52415cabb078bac172d21c1a41dc81520eeca1f1
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Mar 22 18:51:50 2018 +0100
msvcrt: Optimize _strupr implementation in C locale.
Don't write to input buffer when there's nothing to change.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/string.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c
index 2c05e37..d70f235 100644
--- a/dlls/msvcrt/string.c
+++ b/dlls/msvcrt/string.c
@@ -117,6 +117,7 @@ char* CDECL MSVCRT__strlwr(char *str)
*/
int CDECL MSVCRT__strupr_s_l(char *str, MSVCRT_size_t len, MSVCRT__locale_t locale)
{
+ MSVCRT_pthreadlocinfo locinfo;
char *ptr = str;
if (!str || !len)
@@ -138,10 +139,27 @@ int CDECL MSVCRT__strupr_s_l(char *str, MSVCRT_size_t len, MSVCRT__locale_t loca
return MSVCRT_EINVAL;
}
- while (*str)
+ if(!locale)
+ locinfo = get_locinfo();
+ else
+ locinfo = locale->locinfo;
+
+ if(!locinfo->lc_handle[MSVCRT_LC_CTYPE])
{
- *str = MSVCRT__toupper_l((unsigned char)*str, locale);
- str++;
+ while (*str)
+ {
+ if (*str >= 'a' && *str <= 'z')
+ *str -= 'a' - 'A';
+ str++;
+ }
+ }
+ else
+ {
+ while (*str)
+ {
+ *str = MSVCRT__toupper_l((unsigned char)*str, locale);
+ str++;
+ }
}
return 0;
More information about the wine-cvs
mailing list