Re: [PATCH 4/7] ident_split: store begin/end pairs on their own struct
From: Eric Sunshine <hidden>
Date: 2016-06-15 23:01:43
On Wednesday, June 18, 2014, Jeff King [off-list ref] wrote:
Subject: ident_split: store begin/end pairs on their own struct
s/on/in/
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 <redacted> --- 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).