Boost logo

Boost Users :

Subject: Re: [Boost-users] Compress to buffer
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2014-01-14 14:55:14


2014/1/14 Kenneth Adam Miller <kennethadammiller_at_[hidden]>

> Ah ok. I apologize for posting too fast. I will be sure to go further in
> exhausting all resources before I post in the future. However, I did find
> some of the descriptions of the iostreams parts and how they compose
> (especially examples, that's what I was really looking for) vague, IMHO.
>
> No, I haven't measured performance.
>
[...]

> Those unnecessary allocation copies would, in the worst case, result in a
> 2-3x slowdown of the entire program
>

How do you know?

> due to the fact that it's literally pausing to repeat something that's
> unnecessary.
>
> But actually, if this appends my 30k string, I didn't know it. The
> back_insert_device<string> object wasn't something that I understood very
> well from the description at
> http://www.boost.org/doc/libs/1_45_0/libs/iostreams/doc/classes/back_inserter.html
>
> From what I had thought though, if my string was empty with 0's,
>

Right here's your mistake. string(30000,0) creates a non empty string. It's
a string of 30k nulls.

> and I appended to it, then I would end up with precisely my compressed
> data. The idea of acquireStringFromPool is that it returns a large string
> that is always cleared out for the filtering_ostream to fill up as though
> it were a device. Is that incorrect? How can I get that functionality?
>

Like I said, you want std::vector::reserve().

Perhaps, however, that reserve approach would be good. I apologize the
> email was so long lol.
>

Btw, you're still top-posting. The idea is to leave the (minimal) context
above your reply message ;-)

Regards,
Kris



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net