Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Oct 2008 22:50:00 +0200
From:      Max Laier <max@love2party.net>
To:        "Poul-Henning Kamp" <phk@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r183960 - head/usr.bin/ministat
Message-ID:  <200810162250.01303.max@love2party.net>
In-Reply-To: <200810162039.m9GKd21b070051@svn.freebsd.org>
References:  <200810162039.m9GKd21b070051@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 16 October 2008 22:39:02 Poul-Henning Kamp wrote:
> Author: phk
> Date: Thu Oct 16 20:39:02 2008
> New Revision: 183960
> URL: http://svn.freebsd.org/changeset/base/183960
>
> Log:
>   Make ministat(1) vastly faster on huge datasets.
>
> Modified:
>   head/usr.bin/ministat/Makefile
>   head/usr.bin/ministat/ministat.c
...
>  static void
>  AddPoint(struct dataset *ds, double a)
>  {
> -	struct point *pp, *pp2;
> +	double *dp;
>
> -	pp = calloc(1, sizeof *pp);
> -	pp->val = a;
> -
> -	ds->n++;
> +	if (ds->n >= ds->lpoints) {
> +		dp = ds->points;
> +		ds->lpoints *= 4;
> +		ds->points = calloc(sizeof *ds->points, ds->lpoints);
> +		memcpy(ds->points, dp, sizeof *dp * ds->n);

+ free(dp);

???

> +	}
> +	ds->points[ds->n++] = a;
>  	ds->sy += a;
>  	ds->syy += a * a;
> -	if (TAILQ_EMPTY(&ds->list)) {
> -		TAILQ_INSERT_HEAD(&ds->list, pp, list);
> -		return;
> -	}
> -	TAILQ_FOREACH(pp2, &ds->list, list) {
> -		if (pp->val < pp2->val) {
> -			TAILQ_INSERT_BEFORE(pp2, pp, list);
> -			return;
> -		}
> -	}
> -	TAILQ_INSERT_TAIL(&ds->list, pp, list);
>  }

-- 
/"\  Best regards,                      | mlaier@freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810162250.01303.max>