On Wednesday, June 18, 2014, Jeff King <p...@peff.net> wrote:
> Subject: ident_split: store begin/end pairs on their own struct


> When we parse an ident line, we end up with several fields,
> each with a begin/end pointer into the buffer, like:
>   const char *name_begin;
>   const char *name_end;
> There is nothing except the field names to indicate that
> they are paired. This makes it annoying to write helper
> functions for dealing with the sub-fields, as you have to
> pass both sides. Instead, let's move them into a single
> struct "name", with fields "begin" and "end". This will be
> stored identically, but can be passed as a unit.
> We have to do a mechanical update of "s/_/./" at each point
> of use, but other than that, the fields should behave
> identically.
> Signed-off-by: Jeff King <p...@peff.net>
> ---
> Suggestions welcome on the name "pointer_pair".

str_segment  ;-)

> While writing this series, I also noticed that it would be more
> convenient to have a pointer/len combination rather than two pointers.
> You can convert between them, of course, but I found I was always
> converting the other way.
> I left it this way because it makes the mass-update mechanical (and
> because now that I can pass the pair as a unit, I don't have to write
> the same "ident->name_begin, ident->name_end - ident->name_begin" pair
> over and over).
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to