Re: [PATCH 02/18] config: Introduce functions to write non-standard file

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

 



Jeff King wrote:

> BTW, I'm unclear why we bother duplicating the filename in the first
> place. It seems like we could go even simpler with:
>
> int git_config_set_multivar(const char *key, const char *value,
>                             const char *value_regex, int multi_replace)
> {
> 	char *config_filename;
>
> 	if (config_exclusive_filename)
> 		config_filename = config_exclusive_filename;
> 	else
> 		config_filename = git_path("config");
>
>         return git_config_set_multivar_in_file(config_filename, key, value,
>                                                value_regex, multi_replace);

FWIW, I suspect that would be a trap waiting to be triggered as soon
as git_config_set_multivar_in_file() calls git_path() four times.
I.e., it's not about the config_exclusive_filename but about the
git_path.

A little micro-optimization might be to do the following. :)

	const char *config_filename;
	char *filename_buf = NULL;
	int result;

	if (config_exclusive_filename)
		config_filename = config_exclusive_filename;
	else
		config_filename = filename_buf = git_pathdup("config");

	result = git_config_set_multivar_in_file(...);
	free(filename_buf);
	return result;
--
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]