Use std::string as string value storage?

  • Stephen Chu

    Stephen Chu - 2012-02-15

    Is there a plan to add options to use std::string as the storage for string value? Since StaticString doesn't really save any allocation or duplication of string values, maybe switching to std::string will help? The modern C++ standard libraries implement std::string class with reference counting and copy-on-write, which reduces redundant allocation of duplicate strings.

    I am going to try modifying the source to see if I can get it work. Will report back later.

  • henshao

    henshao - 2013-01-03

    Hello, I have the same problem. I found that jsoncpp is so slowly, It always take 10ms to write 60KB json string. I want to improve the performance. I use OProfile to find the problem, then I found that It take much time on the allocation of mermory.

    I change the code of "Value::Value( const Value &other )" function like below. It runs quick a bit.

       case stringValue:
          if ( other.allocated_ )
              if ( other.value_.string_ )
                 value_.string_ = valueAllocator()->duplicateStringValue( other.value_.string_ );
                 allocated_ = true;
                 value_.string_ = 0;
                value_.string_ = other.value_.string_;
                allocated_ = false;


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks