diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-02-24 02:14:12 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-01 18:20:26 +0100 |
commit | 68eb8e5c427877abae43f2e2aba7fcca5a3471de (patch) | |
tree | 75023edde34330665855e8c88573a121e42e2b74 /src/sciteco.h | |
parent | b40fe867e021bc365df1a904c2b1ed2068208f13 (diff) | |
download | sciteco-68eb8e5c427877abae43f2e2aba7fcca5a3471de.tar.gz |
moved String helper functions from sciteco.h and main.cpp to string-utils.cpp and string-utils.h
* also improved performance of String::append() by using g_realloc()
* added String::append() variant for non-null-terminated strings
Diffstat (limited to 'src/sciteco.h')
-rw-r--r-- | src/sciteco.h | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/src/sciteco.h b/src/sciteco.h index 4830312..53131dc 100644 --- a/src/sciteco.h +++ b/src/sciteco.h @@ -66,55 +66,6 @@ extern sig_atomic_t sigint_occurred; #define IS_SUCCESS(X) ((X) < 0) #define IS_FAILURE(X) (!IS_SUCCESS(X)) -namespace String { - -static inline gchar * -chrdup(gchar chr) -{ - gchar *ret = (gchar *)g_malloc(2); - - /* - * NOTE: even the glib allocs are configured to throw exceptions, - * so there is no error handling necessary - */ - ret[0] = chr; - ret[1] = '\0'; - return ret; -} - -static inline void -append(gchar *&str1, const gchar *str2) -{ - /* FIXME: optimize */ - gchar *new_str = g_strconcat(str1 ? : "", str2, NIL); - g_free(str1); - str1 = new_str; -} - -static inline void -append(gchar *&str, gchar chr) -{ - gchar buf[] = {chr, '\0'}; - append(str, buf); -} - -/* in main.cpp */ -void get_coord(const gchar *str, gint pos, - gint &line, gint &column); - -static inline gsize -diff(const gchar *a, const gchar *b) -{ - gsize len = 0; - - while (*a != '\0' && *a++ == *b++) - len++; - - return len; -} - -} /* namespace String */ - namespace Validate { static inline bool |