[gtksourceview] utils: prefer snprintf() over g_snprintf()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] utils: prefer snprintf() over g_snprintf()
- Date: Wed, 24 Apr 2019 18:43:08 +0000 (UTC)
commit 8aea7848a3ded4d51e04c1da55a9f6b540b2c14f
Author: Christian Hergert <chergert redhat com>
Date: Wed Apr 24 11:40:59 2019 -0700
utils: prefer snprintf() over g_snprintf()
Calling g_snprintf() is much slower in a hot-loop than glibc snprintf()
directly, so prefer that when we are on a platform that supports it.
gtksourceview/gtksourceutils.c | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/gtksourceview/gtksourceutils.c b/gtksourceview/gtksourceutils.c
index e6a3ca98..9095aae5 100644
--- a/gtksourceview/gtksourceutils.c
+++ b/gtksourceview/gtksourceutils.c
@@ -588,7 +588,12 @@ _gtk_source_utils_int_to_string (guint value,
return fi.len;
}
+#ifdef G_OS_WIN32
fi.len = g_snprintf (fi.str, sizeof fi.str - 1, "%u", value);
+#else
+ /* Use snprintf() directly when possible to reduce overhead */
+ fi.len = snprintf (fi.str, sizeof fi.str - 1, "%u", value);
+#endif
fi.str[fi.len] = 0;
fi.value = value;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]