[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: better buffer size for copy
From: |
Paul Eggert |
Subject: |
Re: better buffer size for copy |
Date: |
Mon, 07 Nov 2005 12:20:47 -0800 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
It's too much for an inlined function, I think.
/* Buffer primitives for comparison operations.
Copyright (C) 1993, 1995, 1998, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
...
/* Least common multiple of two buffer sizes A and B. However, if
either A or B is zero, or if the multiple is greater than LCM_MAX,
return a reasonable buffer size. */
size_t
buffer_lcm (size_t a, size_t b, size_t lcm_max)
{
size_t lcm, m, n, q, r;
/* Yield reasonable values if buffer sizes are zero. */
if (!a)
return b ? b : 8 * 1024;
if (!b)
return a;
/* n = gcd (a, b) */
for (m = a, n = b; (r = m % n) != 0; m = n, n = r)
continue;
/* Yield a if there is an overflow. */
q = a / n;
lcm = q * b;
return lcm <= lcm_max && lcm / b == q ? lcm : a;
}
- better buffer size for copy, Robert Latham, 2005/11/04
- Re: better buffer size for copy, Paul Eggert, 2005/11/05
- Re: better buffer size for copy, Robert Latham, 2005/11/07
- Re: better buffer size for copy,
Paul Eggert <=
- Re: better buffer size for copy, Robert Latham, 2005/11/07
- Re: better buffer size for copy, Robert Latham, 2005/11/18
- Re: better buffer size for copy, Phillip Susi, 2005/11/19
- Re: better buffer size for copy, Robert Latham, 2005/11/20
- Re: better buffer size for copy, Phillip Susi, 2005/11/21
- Re: better buffer size for copy, Robert Latham, 2005/11/22
- Re: better buffer size for copy, Phillip Susi, 2005/11/22
- Re: better buffer size for copy, Paul Eggert, 2005/11/24
- Re: better buffer size for copy, Jim Meyering, 2005/11/24