chiark / gitweb /
locale-util: mark special_glyph() as _const_
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 9 May 2016 15:24:08 +0000 (11:24 -0400)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:12:58 +0000 (10:12 +0200)
_const_ means that the caller can assume that the function will return the same
result every time (and will not modify global memory). special_glyph() meets
this: even though it depends on global memory, that part of global memory is
not expected to change. This allows the calls to special_glyph() to be
optimized, even if -flto is not used.

src/basic/locale-util.c
src/basic/locale-util.h

index 8134f61a73fef98d806166863af5c2b4944baa8b..ada0a28cd8423d84ec628422a3c9a4622dd83dd3 100644 (file)
@@ -273,7 +273,7 @@ out:
 
 const char *special_glyph(SpecialGlyph code) {
 
 
 const char *special_glyph(SpecialGlyph code) {
 
-        static const char *draw_table[2][_SPECIAL_GLYPH_MAX] = {
+        static const char* const draw_table[2][_SPECIAL_GLYPH_MAX] = {
                 /* ASCII fallback */
                 [false] = {
                         [TREE_VERTICAL]      = "| ",
                 /* ASCII fallback */
                 [false] = {
                         [TREE_VERTICAL]      = "| ",
index 353b7845fdfcded6fc1bcb64d04925188257f6ec..0630a034ab475f48552062c43d9567c9b2a42f7c 100644 (file)
@@ -67,7 +67,7 @@ typedef enum {
         _SPECIAL_GLYPH_MAX
 } SpecialGlyph;
 
         _SPECIAL_GLYPH_MAX
 } SpecialGlyph;
 
-const char *special_glyph(SpecialGlyph code);
+const char *special_glyph(SpecialGlyph code) _const_;
 
 const char* locale_variable_to_string(LocaleVariable i) _const_;
 LocaleVariable locale_variable_from_string(const char *s) _pure_;
 
 const char* locale_variable_to_string(LocaleVariable i) _const_;
 LocaleVariable locale_variable_from_string(const char *s) _pure_;