[libxslt] Avoid double/long round trip in FORMAT_ITEM
- From: Nick Wellnhofer <nwellnhof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libxslt] Avoid double/long round trip in FORMAT_ITEM
- Date: Thu, 18 May 2017 16:25:51 +0000 (UTC)
commit bf43ea2de184b2947dc1a256abb8cbf7edea8cda
Author: Nick Wellnhofer <wellnhofer aevum de>
Date: Thu May 18 17:27:54 2017 +0200
Avoid double/long round trip in FORMAT_ITEM
libexslt/date.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/libexslt/date.c b/libexslt/date.c
index dd75a44..8687802 100644
--- a/libexslt/date.c
+++ b/libexslt/date.c
@@ -1171,14 +1171,12 @@ error:
* @item: char designator
*
*/
-#define FORMAT_ITEM(num, cur, limit, item) \
- if (num != 0) { \
- long comp = (long)num / limit; \
- if (comp != 0) { \
- FORMAT_FLOAT((double)comp, cur, 0); \
- *cur++ = item; \
- num -= (double)(comp * limit); \
- } \
+#define FORMAT_ITEM(num, cur, limit, item) \
+ if (num >= limit) { \
+ double comp = floor(num / limit); \
+ FORMAT_FLOAT(comp, cur, 0); \
+ *cur++ = item; \
+ num -= comp * limit; \
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]