[6/6] vfprintf: Remove label name switching for the jump table
diff mbox

Message ID 8a9dc15454643f23c9309335b8fbbaadddabcd99.1425246936.git.fweimer@redhat.com
State New
Headers show

Commit Message

Florian Weimer March 1, 2015, 9:19 p.m. UTC
Different labels are no longer needed because the tables are now in
separate functions.
---
 stdio-common/vfprintf.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

Comments

Carlos O'Donell May 20, 2015, 2:13 p.m. UTC | #1
On 03/01/2015 04:19 PM, Florian Weimer wrote:
> Different labels are no longer needed because the tables are now in
> separate functions.
> ---
>  stdio-common/vfprintf.c | 21 ++++-----------------
>  1 file changed, 4 insertions(+), 17 deletions(-)

This looks good to me and simplifies the code, which is always
a win for vfprintf.

Cheers,
Carlos.

> diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
> index 6e840aa..6bf59ff 100644
> --- a/stdio-common/vfprintf.c
> +++ b/stdio-common/vfprintf.c
> @@ -252,9 +252,12 @@ static const uint8_t jump_table[] =
>  
>  #define NOT_IN_JUMP_RANGE(Ch) ((Ch) < L_(' ') || (Ch) > L_('z'))
>  #define CHAR_CLASS(Ch) (jump_table[(INT_T) (Ch) - L_(' ')])
> +#define LABEL(Name) do_##Name
>  #ifdef SHARED
>    /* 'int' is enough and it saves some space on 64 bit systems.  */
>  # define JUMP_TABLE_TYPE const int
> +# define JUMP_TABLE_BASE_LABEL do_form_unknown
> +# define REF(Name) &&do_##Name - &&JUMP_TABLE_BASE_LABEL
>  # define JUMP(ChExpr, table)						      \
>        do								      \
>  	{								      \
> @@ -269,6 +272,7 @@ static const uint8_t jump_table[] =
>        while (0)
>  #else
>  # define JUMP_TABLE_TYPE const void *const
> +# define REF(Name) &&do_##Name
>  # define JUMP(ChExpr, table)						      \
>        do								      \
>  	{								      \
> @@ -1328,13 +1332,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
>    /* Process whole format string.  */
>    do
>      {
> -#ifdef SHARED
> -# define JUMP_TABLE_BASE_LABEL do_form_unknown
> -# define REF(Name) &&do_##Name - &&JUMP_TABLE_BASE_LABEL
> -#else
> -# define REF(Name) &&do_##Name
> -#endif
> -#define LABEL(Name) do_##Name
>        STEP0_3_TABLE;
>        STEP4_TABLE;
>  
> @@ -1928,16 +1925,6 @@ printf_positional (_IO_FILE *s, const CHAR_T *format, int readonly_format,
>    /* Now walk through all format specifiers and process them.  */
>    for (; (size_t) nspecs_done < nspecs; ++nspecs_done)
>      {
> -#undef REF
> -#ifdef SHARED
> -# undef JUMP_TABLE_BASE_LABEL
> -# define JUMP_TABLE_BASE_LABEL do2_form_unknown
> -# define REF(Name) &&do2_##Name - &&JUMP_TABLE_BASE_LABEL
> -#else
> -# define REF(Name) &&do2_##Name
> -#endif
> -#undef LABEL
> -#define LABEL(Name) do2_##Name
>        STEP4_TABLE;
>  
>        int is_negative;
>

Patch
diff mbox

diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 6e840aa..6bf59ff 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -252,9 +252,12 @@  static const uint8_t jump_table[] =
 
 #define NOT_IN_JUMP_RANGE(Ch) ((Ch) < L_(' ') || (Ch) > L_('z'))
 #define CHAR_CLASS(Ch) (jump_table[(INT_T) (Ch) - L_(' ')])
+#define LABEL(Name) do_##Name
 #ifdef SHARED
   /* 'int' is enough and it saves some space on 64 bit systems.  */
 # define JUMP_TABLE_TYPE const int
+# define JUMP_TABLE_BASE_LABEL do_form_unknown
+# define REF(Name) &&do_##Name - &&JUMP_TABLE_BASE_LABEL
 # define JUMP(ChExpr, table)						      \
       do								      \
 	{								      \
@@ -269,6 +272,7 @@  static const uint8_t jump_table[] =
       while (0)
 #else
 # define JUMP_TABLE_TYPE const void *const
+# define REF(Name) &&do_##Name
 # define JUMP(ChExpr, table)						      \
       do								      \
 	{								      \
@@ -1328,13 +1332,6 @@  vfprintf (FILE *s, const CHAR_T *format, va_list ap)
   /* Process whole format string.  */
   do
     {
-#ifdef SHARED
-# define JUMP_TABLE_BASE_LABEL do_form_unknown
-# define REF(Name) &&do_##Name - &&JUMP_TABLE_BASE_LABEL
-#else
-# define REF(Name) &&do_##Name
-#endif
-#define LABEL(Name) do_##Name
       STEP0_3_TABLE;
       STEP4_TABLE;
 
@@ -1928,16 +1925,6 @@  printf_positional (_IO_FILE *s, const CHAR_T *format, int readonly_format,
   /* Now walk through all format specifiers and process them.  */
   for (; (size_t) nspecs_done < nspecs; ++nspecs_done)
     {
-#undef REF
-#ifdef SHARED
-# undef JUMP_TABLE_BASE_LABEL
-# define JUMP_TABLE_BASE_LABEL do2_form_unknown
-# define REF(Name) &&do2_##Name - &&JUMP_TABLE_BASE_LABEL
-#else
-# define REF(Name) &&do2_##Name
-#endif
-#undef LABEL
-#define LABEL(Name) do2_##Name
       STEP4_TABLE;
 
       int is_negative;