Re: [PATCH 3/9] Rename cryptic 'which' variable to more consistent name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adam Spiers <git@xxxxxxxxxxxxxx> writes:

> 'el' is only *slightly* less cryptic, but is already used as the
> variable name for a struct exclude_list pointer in numerous other
> places, so this reduces the number of cryptic variable names in use by
> one :-)

The name originally meant to mean "to which element of the array
dir_struct.exclude_list[] are we adding this entry?" but I agree
"el" that stands for ExcludeList would be a better name.

Often we use "el" (or "elem") for elements of an iterable we are
iterating on in a loop, and the name of the iterable does not have
to be EsomethingLsomething, by the way.  Because no existing use of
"el" in this file is of that kind, I do not think this change
introduces new confusion to the code.

> Signed-off-by: Adam Spiers <git@xxxxxxxxxxxxxx>
> ---
>  dir.c | 10 +++++-----
>  dir.h |  4 ++--
>  2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/dir.c b/dir.c
> index c9f341a..57a5d11 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -311,7 +311,7 @@ static int no_wildcard(const char *string)
>  }
>  
>  void add_exclude(const char *string, const char *base,
> -		 int baselen, struct exclude_list *which)
> +		 int baselen, struct exclude_list *el)
>  {
>  	struct exclude *x;
>  	size_t len;
> @@ -346,8 +346,8 @@ void add_exclude(const char *string, const char *base,
>  	x->nowildcardlen = simple_length(string);
>  	if (*string == '*' && no_wildcard(string+1))
>  		x->flags |= EXC_FLAG_ENDSWITH;
> -	ALLOC_GROW(which->excludes, which->nr + 1, which->alloc);
> -	which->excludes[which->nr++] = x;
> +	ALLOC_GROW(el->excludes, el->nr + 1, el->alloc);
> +	el->excludes[el->nr++] = x;
>  }
>  
>  static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
> @@ -389,7 +389,7 @@ int add_excludes_from_file_to_list(const char *fname,
>  				   const char *base,
>  				   int baselen,
>  				   char **buf_p,
> -				   struct exclude_list *which,
> +				   struct exclude_list *el,
>  				   int check_index)
>  {
>  	struct stat st;
> @@ -436,7 +436,7 @@ int add_excludes_from_file_to_list(const char *fname,
>  		if (buf[i] == '\n') {
>  			if (entry != buf + i && entry[0] != '#') {
>  				buf[i - (i && buf[i-1] == '\r')] = 0;
> -				add_exclude(entry, base, baselen, which);
> +				add_exclude(entry, base, baselen, el);
>  			}
>  			entry = buf + i + 1;
>  		}
> diff --git a/dir.h b/dir.h
> index a226fbc..549a187 100644
> --- a/dir.h
> +++ b/dir.h
> @@ -117,10 +117,10 @@ extern int path_excluded(struct path_exclude_check *, const char *, int namelen,
>  
>  
>  extern int add_excludes_from_file_to_list(const char *fname, const char *base, int baselen,
> -					  char **buf_p, struct exclude_list *which, int check_index);
> +					  char **buf_p, struct exclude_list *el, int check_index);
>  extern void add_excludes_from_file(struct dir_struct *, const char *fname);
>  extern void add_exclude(const char *string, const char *base,
> -			int baselen, struct exclude_list *which);
> +			int baselen, struct exclude_list *el);
>  extern void free_excludes(struct exclude_list *el);
>  extern int file_exists(const char *);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]