-
2008.08.19 16:05 "Re: [Tiff] Regarding DICONDE and its Specification", by Bob Friesenhahn
- 2008.08.20 12:37 "Re: [Tiff] Regarding DICONDE and its Specification", by Harsha
- 2008.08.20 14:03 "Re: [Tiff] Regarding DICONDE and its Specification", by Gene Amtower
-
2008.08.22 15:21 "Re: [Tiff] creating sparse files......", by Toby Thain
-
2008.08.22 08:56 "[Tiff] creating sparse files......", by Rogier Wolff
- 2008.08.22 13:11 "Re: [Tiff] creating sparse files......", by Toby Thain
-
2008.08.22 14:44 "Re: [Tiff] creating sparse files......", by Bob Friesenhahn
-
2008.08.22 16:27 "Re: [Tiff] creating sparse files......", by Rogier Wolff
-
2008.08.22 16:40 "Re: [Tiff] creating sparse files......", by Bob Friesenhahn
-
2008.08.22 16:52 "Re: [Tiff] creating sparse files......", by Rogier Wolff
-
2008.08.22 18:11 "Re: [Tiff] creating sparse files......", by Bob Friesenhahn
- 2008.08.22 20:02 "Re: [Tiff] creating sparse files......", by Phillip Crews
- 2008.08.23 15:08 "Re: [Tiff] creating sparse files......", by Rogier Wolff
-
2008.08.22 18:11 "Re: [Tiff] creating sparse files......", by Bob Friesenhahn
-
2008.08.22 16:52 "Re: [Tiff] creating sparse files......", by Rogier Wolff
-
2008.08.22 16:40 "Re: [Tiff] creating sparse files......", by Bob Friesenhahn
-
2008.08.22 16:27 "Re: [Tiff] creating sparse files......", by Rogier Wolff
- 2008.08.25 06:28 "Re: [Tiff] creating sparse files......", by Andrey Kiselev
- 2008.08.25 09:37 "Re: [Tiff] creating sparse files......", by John
- 2008.08.26 13:14 "Re: [Tiff] creating sparse files......", by Edward Lam
- 2008.08.23 18:49 "Re: [Tiff] creating sparse files......", by Rogier Wolff
-
2008.08.22 08:56 "[Tiff] creating sparse files......", by Rogier Wolff
2008.08.22 16:26 "Re: [Tiff] creating sparse files......", by Toby Thain
On 22-Aug-08, at 12:45 PM, Rogier Wolff wrote:
On Fri, Aug 22, 2008 at 10:11:42AM -0300, Toby Thain wrote:
static int isallzero (tdata_t buf, tsize_t size)
{
int i;
for (i=0;i<size;i++)
if (buf[i]) return 0;
return 1;
}This appears unnecessarily inefficient. It's going to be much cheaper to test whole longwords (or whatever data alignment will allow) than byte by byte. (I wonder if something clever can be done with MMX/SSE on newer chips?)
Yes, this is the "quick and dirty" implementation of this function. The advantage of doing it this simple is that it will ALWAYS work.
Anway, my philosophy is always FIRST get it to work, optimize later.
Yes my nitpicking was probably premature. :)
static tsize_t
_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
{
if (isallzero (buf, size))
return (lseek ((int) fd, (off_t)size, SEEK_CUR));
else
return ((tsize_t) write((int) fd, buf, (size_t) size));
}This penalises all writes to optimise a very special case. Not saying it can't be rationalised, but pros and cons can be debated.
And you're calling this an optimization. And I agree. However, in my case saving a factor of 21 on disk space is i'd say "worth it".
But, yes, officially it could cost you some CPU cycles, which are not returned by saving on writes. (checking for zeroes and seeking is much more efficient than just doing the write! It not only saves you disk space, but also CPU cycles!)
Well this is the kind of debate I was hinting at. :)
I think Bob's suggestion of compression is a very good one and perfectly portable? (Taking into account the filesystem differences you mentioned.)
--Toby
>
> Roger.
>