[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: |
ml-monotone |
Subject: |
Re: [Monotone-devel] Patch to speed up add operation |
Date: |
Thu, 25 Aug 2005 06:26:05 +0200 (CEST) |
Benoît Dejean wrote:
(...)
> 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());
Allthough most (all?) STL implementations so far implement std::string
using contiguous memory, the standard does not mandate it. Only the
pointer returned by std::string::c_str() points to contiguous memory
useable by C for reading only (valid only until next modification of
that std::string instance).
Scott Meyers has stated, that the only container forseen to be used with
C libraries is std::vector, where the trick above shall work.
(...)
> am I being to picky ? :)
I think it is good you mentioned it, as it has impact on portability.
Ciao,
Clemens.