From 723b75534632a99228a7266d7579c9d8b3f0cb77 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 10 Feb 2016 16:30:16 +0100 Subject: 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%. --- src/string-utils.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/string-utils.h') 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 @@ -26,6 +26,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. */ -- cgit v1.2.3