Thread: boost iostreams and compression

  1. #1
    Registered User
    Join Date
    May 2006

    boost iostreams and compression


    I've been trying to figure out another way to compress data from/to std::stringstream.

    Here is the source how I do it now:

     std::stringstream decompressed;
     decompressed << "somestring.....";
     std::stringstream compressed;
      boost::iostreams::filtering_streambuf<boost::iostreams::input> out;
      boost::iostreams::copy(out, compressed);

    Is there any way around this?
    I want to avoid boost::iostreams::copy because it takes 40% of this source execution time.
    How can I compress data directly to stringstream (to compressed in this example) without copying it?

    PS: i tried asking on boost user newsgroups, but noone replies

    Thank you very much for help

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Must have missed the post on boost-users.

    Anyway, you mean that copy takes 40&#37; of the time of this snippet? Actually, I'd expect it to use about 95% - it's the only part that does any work.

    But you might try an array_sink instead of the stringstream as the target.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    May 2006
    Could you give an example please?

Popular pages Recent additions subscribe to a feed