Thread: boost iostreams and compression

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    630

    boost iostreams and compression

    Hello

    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:

    Code:
     std::stringstream decompressed;
     decompressed << "somestring.....";
    
     std::stringstream compressed;
     {
      boost::iostreams::filtering_streambuf<boost::iostreams::input> out;
      out.push(boost::iostreams::zlib_compressor());
      out.push(decompressed);
      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
    Posts
    8,895
    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!
    CornedBee

    "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
    Posts
    630
    Could you give an example please?

Popular pages Recent additions subscribe to a feed