aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/string-utils.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-10 16:30:16 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-10 16:30:16 +0100
commit723b75534632a99228a7266d7579c9d8b3f0cb77 (patch)
treedb1cae271ddf0723090f99f5a190ad83b986222b /src/string-utils.h
parent1da5bdeb986657c5cfd83d495d15b7f2308d3b5b (diff)
downloadsciteco-723b75534632a99228a7266d7579c9d8b3f0cb77.tar.gz
added String::toupper(): minor optimization
* This is one of the most called functions (although a cheap one), so having our own inline implementation speeds up things. Benchmarks have shown that parsing is sped up by at least 4%.
Diffstat (limited to 'src/string-utils.h')
-rw-r--r--src/string-utils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/string-utils.h b/src/string-utils.h
index 4eee958..559e590 100644
--- a/src/string-utils.h
+++ b/src/string-utils.h
@@ -27,6 +27,18 @@ namespace SciTECO {
namespace String {
/**
+ * Upper-case ASCII character.
+ *
+ * There are implementations in glib and libc,
+ * but defining it here ensures it can be inlined.
+ */
+static inline gchar
+toupper(gchar chr)
+{
+ return chr >= 'a' && chr <= 'z' ? chr & ~0x20 : chr;
+}
+
+/**
* Allocate a string containing a single character chr.
*/
static inline gchar *