[Insight-developers] PatCh to MetaIO for bug 9766

Julien Jomier julien.jomier at kitware.com
Wed Nov 4 12:03:51 EST 2009


Hi Brad,

> I have two style questions:
> 
> 1) I need a constant for the maximum file chuck to read ( I am going to 
> set it to 1GB ). Currently, I have it as a static constant in 
> metaImage.cxx, but should it be some place else.... metaUtils?

If it's only going to affect MetaImage, I'll just keep it in metaImage.cxx

> 2) I also debated about if this tight loop over an stream::read should 
> be separated into a function. But after considering the depth of Read 
> methods that already exist, I don't think it's necessary. The patch 
> basically consists of 5 changes similar to the following:
> 
> @@ -3310,9 +3357,18 @@
>            }
>          else // binary data
>            {
> -          _fstream->read(data, readLine);
> -          gc += _fstream->gcount();
> -          data += _fstream->gcount();
> +  
> +          // the data is read with calls no bigger then MaxIOChunk
> +          size_t bytesRemaining = readLine;
> +          while ( bytesRemaining )
> +            {
> +            size_t chunkToRead = bytesRemaining > MaxIOChunk ? 
> MaxIOChunk : bytesRemaining;
> +            _fstream->read( (char *)data, chunkToRead );
> +            data = (char *)(data) + chunkToRead; // <- Note: _data is 
> changed
> +            bytesRemaining -= chunkToRead;
> +            gc += _fstream->gcount();
> +            }
> +
>            }
>          }

I'd say if it's easy to put it in a function, then we should do it. 
Otherwise I don't see any major issues duplicating the code.

Thanks again for fixing this,
Julien



More information about the Insight-developers mailing list