From 68eb8e5c427877abae43f2e2aba7fcca5a3471de Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 24 Feb 2015 02:14:12 +0100 Subject: 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 --- src/sciteco.h | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) (limited to 'src/sciteco.h') 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 -- cgit v1.2.3