This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
A small optimization patch
- To: GNU C Library <libc-alpha at sourceware dot cygnus dot com>
- Subject: A small optimization patch
- From: "H . J . Lu" <hjl at valinux dot com>
- Date: Fri, 1 Dec 2000 23:46:15 -0800
Here is a small optimization patch.
--
H.J. Lu (hjl@valinux.com)
---
2000-12-01 H.J. Lu <hjl@gnu.org>
* locale/lc-time.c (_nl_init_era_entries): Optimize out
wcschr.
(_nl_get_walt_digit): Likewise.
* stdio-common/printf_fp.c (group_number): Optimize out
__wmemmove.
Index: locale/lc-time.c
===================================================================
RCS file: /work/cvs/gnu/glibc/locale/lc-time.c,v
retrieving revision 1.1.1.3
diff -u -p -r1.1.1.3 lc-time.c
--- locale/lc-time.c 2000/08/21 05:10:30 1.1.1.3
+++ locale/lc-time.c 2000/12/02 07:15:33
@@ -86,6 +86,7 @@ _nl_init_era_entries (void)
else
{
const char *ptr = _NL_CURRENT (LC_TIME, _NL_TIME_ERA_ENTRIES);
+ wchar_t *wptr;
num_eras = new_num_eras;
for (cnt = 0; cnt < num_eras; ++cnt)
@@ -121,11 +122,13 @@ _nl_init_era_entries (void)
/* Set and skip wide era name. */
eras[cnt].era_wname = (wchar_t *) ptr;
- ptr = (char *) (wcschr ((wchar_t *) ptr, '\0') + 1);
+ for (wptr = (wchar_t *) ptr; *wptr != L'\0'; wptr++);
+ ptr = (char *) (wptr + 1);
/* Set and skip wide era format. */
eras[cnt].era_wformat = (wchar_t *) ptr;
- ptr = (char *) (wcschr ((wchar_t *) ptr, '\0') + 1);
+ for (wptr = (wchar_t *) ptr; *wptr != L'\0'; wptr++);
+ ptr = (char *) (wptr + 1);
}
}
}
@@ -237,7 +240,8 @@ _nl_get_walt_digit (unsigned int number)
walt_digits[cnt] = ptr;
/* Skip digit format. */
- ptr = wcschr (ptr, L'\0') + 1;
+ while (*ptr++ != L'\0');
+ ptr++;
}
}
}
Index: stdio-common/printf_fp.c
===================================================================
RCS file: /work/cvs/gnu/glibc/stdio-common/printf_fp.c,v
retrieving revision 1.1.1.4
diff -u -p -r1.1.1.4 printf_fp.c
--- stdio-common/printf_fp.c 2000/11/07 01:29:01 1.1.1.4
+++ stdio-common/printf_fp.c 2000/12/02 07:02:56
@@ -1192,8 +1192,8 @@ group_number (wchar_t *buf, wchar_t *buf
return bufend;
/* Move the fractional part down. */
- __wmemmove (buf + intdig_no + ngroups, buf + intdig_no,
- bufend - (buf + intdig_no));
+ memmove (&buf [intdig_no + ngroups], &buf [intdig_no],
+ sizeof (wchar_t) * (bufend - (buf + intdig_no)));
p = buf + intdig_no + ngroups - 1;
do