* lib/vasnprintf.c (VASNPRINTF): Optimize a few loops.
2025-04-13 Bruno Haible <bruno@clisp.org>
+ vasnprintf: Optimize last commit.
+ * lib/vasnprintf.c (VASNPRINTF): Optimize a few loops.
+
vasnprintf: Consider the grouping rule.
Reported by Pádraig Brady.
* lib/vasnprintf.c (grouping_rule, num_thousands_separators): New
int h = *g;
if (h <= 0)
abort ();
- int i;
- for (i = h; i > 0; i--)
+ int i = h;
+ do
*--p = *digitp++;
+ while (--i > 0);
# if WIDE_CHAR_VERSION
*--p = thousep[0];
# else
int h = *g;
if (h <= 0)
abort ();
- int i;
- for (i = h; i > 0; i--)
+ int i = h;
+ do
*--p = *digitp++;
+ while (--i > 0);
# if WIDE_CHAR_VERSION
*--p = thousep[0];
# else
int h = *g;
if (h <= 0)
abort ();
- int i;
- for (i = h; i > 0; i--)
+ int i = h;
+ do
*--p = *digitp++;
+ while (--i > 0);
# if WIDE_CHAR_VERSION
*--p = thousep[0];
# else
int h = *g;
if (h <= 0)
abort ();
- int i;
- for (i = h; i > 0; i--)
+ int i = h;
+ do
*--p = *digitp++;
+ while (--i > 0);
# if WIDE_CHAR_VERSION
*--p = thousep[0];
# else
int h = *g;
if (h <= 0)
abort ();
- int i;
- for (i = h; i > 0; i--)
+ int i = h;
+ do
*--q = *--p;
+ while (--i > 0);
# if WIDE_CHAR_VERSION && DCHAR_IS_TCHAR
- *--q = *thousep;
+ *--q = *thousep;
# else
- q -= thousep_len;
- memcpy (q, thousep, thousep_len);
+ q -= thousep_len;
+ memcpy (q, thousep, thousep_len);
# endif
insert--;
if (insert == 0)