[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] Patch to speed up add operation
From: |
Benoît Dejean |
Subject: |
Re: [Monotone-devel] Patch to speed up add operation |
Date: |
Wed, 24 Aug 2005 23:15:56 +0200 |
Le mercredi 24 août 2005 à 11:49 -0700, Eric Anderson a écrit :
> Summary: The attached patch changes the function which determines if a file
> Since guess_binary() took a string, I used the slightly questionable:
> &string[0] trick to get a writeable pointer to the string in
> file.read(&buf[0],bufsize) in monotone_guess_binary_filename_for_lua.
> Does anyone know of a way to just read up to some number of bytes into
> a string? If not, should guess_binaries signature be changed to
> guess_binary(unsigned char *data, int datalen) and a char[bufsize] array
> be used instead of a string?
i can't find anything saying that string uses contiguous storage. Better
use vector. So the following is buggy :
+ while(file.good())
+ {
+ buf.resize(bufsize);
+ file.read(&buf[0],bufsize);
+ buf.resize(file.gcount());
Moreover, istream usage is bad. Better write
while(file.read(..., ...)) { }
am I being to picky ? :)
--
Benoît Dejean <benoit AT placenet DOT org>
JID: address@hidden
GNOME http://www.gnomefr.org/
LibGTop http://directory.fsf.org/libgtop.html
signature.asc
Description: This is a digitally signed message part