This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] gconv: Replace norm_add_slashes with __gconv_norm_add_slashes


On 06/20/2017 09:12 PM, Adhemerval Zanella wrote:
> +char *
> +__gconv_norm_add_slashes (const char *name, size_t name_len,
> +                          const char *suffix)
> +{
> +  size_t cnt = 0;
> +  for (size_t i = 0; i < name_len; i++)
> +    if (name[i] == '/')
> +      cnt++;
> +
> +  struct char_array result;
> +  if (!char_array_init_str_size (&result, name, name_len))
> +    return NULL;
> +
> +  for (size_t i = 0; i < char_array_length (&result); i++)
> +    *char_array_at (&result, i) = __toupper_l (name[i], _nl_C_locobj_ptr);
> +
> +  if (cnt < 2)
> +    {
> +      if (!char_array_append_str (&result, "/"))
> +	return NULL;
> +      if (cnt < 1)
> +        {
> +	  if (!char_array_append_str (&result, "/")
> +	      | !char_array_append_str (&result, suffix))
> +	    return NULL;
> +        }
> +    }
> +
> +  return char_array_finalize (&result, NULL);
> +}

Thanks for posting this.  I'll plan to compare this with a plain
dynarray-based implementation, to see what the generated code is like in
both cases.

Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]