l10ntools/source/export2.cxx | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
New commits: commit b4c9dd86123180e7ca5ffade6cc5d41ce54c7885 Author: Herbert Dürr <h...@apache.org> Date: Mon Jun 23 12:48:27 2014 +0000 #i125143# use bulk-copying instead of line-wise in helpex Export::CopyFile() This simple change has been measured to speed up the helpex by almost 30%. diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx index 34df550..1608a09 100644 --- a/l10ntools/source/export2.cxx +++ b/l10ntools/source/export2.cxx @@ -339,7 +339,7 @@ void Export::RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename ){ bool Export::CopyFile( const ByteString& source , const ByteString& dest ) { // cout << "CopyFile( " << source.GetBuffer() << " , " << dest.GetBuffer() << " )\n"; - const int BUFFERSIZE = 8192; + static const int BUFFERSIZE = 0x100000; char buf[ BUFFERSIZE ]; FILE* IN_FILE = fopen( source.GetBuffer() , "r" ); @@ -357,27 +357,30 @@ bool Export::CopyFile( const ByteString& source , const ByteString& dest ) return false; } - while( fgets( buf , BUFFERSIZE , IN_FILE ) != NULL ) + bool bOk = true; + while( bOk ) { - if( fputs( buf , OUT_FILE ) == EOF ) + if( feof( IN_FILE ) ) + break; + const size_t nBytesRead = fread( buf, 1, BUFFERSIZE, IN_FILE ); + if( nBytesRead <= 0 ) + { + if( ferror( IN_FILE ) ) + { + cerr << "Export::CopyFile WARNING: Read problems " << dest.GetBuffer() << "\n"; + bOk = false; + } + } + else if( fwrite( buf, 1, nBytesRead, OUT_FILE ) <= 0 ) { cerr << "Export::CopyFile WARNING: Write problems " << source.GetBuffer() << "\n"; - fclose( IN_FILE ); - fclose( OUT_FILE ); - return false; + bOk = false; } } - if( ferror( IN_FILE ) ) - { - cerr << "Export::CopyFile WARNING: Read problems " << dest.GetBuffer() << "\n"; - fclose( IN_FILE ); - fclose( OUT_FILE ); - return false; - } fclose ( IN_FILE ); fclose ( OUT_FILE ); - return true; + return bOk; } /*****************************************************************************/
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits