[gnome-builder] macros: just use strlen() for literal size



commit b006e6f147f31ed37151c4ed36b7724e73dd2f6e
Author: Christian Hergert <christian hergert me>
Date:   Mon Feb 15 13:46:02 2016 -0800

    macros: just use strlen() for literal size
    
    GCC and clang supposedly both hoist this out automatically, so no need
    to be clever to get compile-time sizes.

 libide/ide-macros.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-macros.h b/libide/ide-macros.h
index 1a907dc..65bcd33 100644
--- a/libide/ide-macros.h
+++ b/libide/ide-macros.h
@@ -20,6 +20,7 @@
 #define IDE_MACROS_H
 
 #include <glib-object.h>
+#include <string.h>
 
 G_BEGIN_DECLS
 
@@ -46,7 +47,8 @@ G_BEGIN_DECLS
     } \
   } G_STMT_END
 
-#define IDE_LITERAL_LENGTH(s) ((sizeof s)-1)
+/* strlen() generally gets hoisted out automatically */
+#define IDE_LITERAL_LENGTH(s) (strlen(s))
 
 static inline gboolean
 ide_str_empty0 (const gchar *str)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]