git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Brian Downing <bdowning@lavos.net>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Nicolas Pitre <nico@cam.org>
Subject: Re: [PATCH 3/6] Add functions for parsing integers with size suffixes
Date: Thu, 12 Jul 2007 14:07:39 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707121404450.4516@racer.site> (raw)
In-Reply-To: <1184244952173-git-send-email-bdowning@lavos.net>

Hi,

On Thu, 12 Jul 2007, Brian Downing wrote:

> Split out the nnn{k,m,g} parsing code from git_config_int into 
> git_parse_long, so command-line parameters can enjoy the same 
> functionality.  Also add get_parse_ulong for unsigned values.

Nice!

> +		if (!*end)
> +			*ret = val;
> +		else if (!strcasecmp(end, "k"))
> +			*ret = val * 1024;
> +		else if (!strcasecmp(end, "m"))
> +			*ret = val * 1024 * 1024;
> +		else if (!strcasecmp(end, "g"))
> +			*ret = val * 1024 * 1024 * 1024;
> +		else
> +			return 0;

This could be an own static function, like this:

unsigned long get_unit_factor(const char *end)
{
	if (!*end)
		return 1;
	if (!strcasecmp(end, "k"))
		return 1024;
	...
	error("Unknown unit: %s", end);
	return 1;
}

to avoid duplicated code.

Ciao,
Dscho

  reply	other threads:[~2007-07-12 13:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-12 12:55 [PATCH 0/6] Pack window memory limit, take 2 Brian Downing
2007-07-12 12:55 ` [PATCH 1/6] Don't try to delta if target is much smaller than source Brian Downing
2007-07-12 12:55 ` [PATCH 2/6] Support fetching the memory usage of a delta index Brian Downing
2007-07-12 12:55 ` [PATCH 3/6] Add functions for parsing integers with size suffixes Brian Downing
2007-07-12 13:07   ` Johannes Schindelin [this message]
2007-07-12 13:32     ` [PATCH] " Brian Downing
2007-07-12 12:55 ` [PATCH 4/6] Add pack-objects window memory usage limit Brian Downing
2007-07-12 13:04   ` Brian Downing
2007-07-12 13:07     ` [PATCH] " Brian Downing
2007-07-12 12:55 ` [PATCH 5/6] Add --window-memory option to git-repack Brian Downing
2007-07-12 12:55 ` [PATCH 6/6] Add documentation for --window-memory, pack.windowMemory Brian Downing
2007-07-12 15:46 ` [PATCH 0/6] Pack window memory limit, take 2 Nicolas Pitre
2007-07-13 18:23 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0707121404450.4516@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=bdowning@lavos.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nico@cam.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).