Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

4.11 Performance Considerations

The Essential Tools Module provides two implementations of RWCString and RWWString. While these different implementations have the same basic API, each features performance characteristics that are tuned to particular usage scenarios.

Table 7 shows the relationship between the two classes.

Table 7: Comparison of Standard Strings with Copy-on-Write Strings

Classes Description
RWStandardCString
RWStandardWString
  • Based on the C++ Standard Library std::string or std::wstring respectively.

  • Provide additional APIs for retrieving the underlying std::string or std::wstring instance.

  • Take advantage of C++ Standard Library implementation-specific optimizations (e.g., Copy-on-Write, short-string optimizations, etc.)

RWCopyOnWriteCString
RWCopyOnWriteWString
  • Implement a Copy-on-Write pattern to prevent unnecessary duplication in use cases when strings are seldom or never modified.

  • On platforms where the C++ Standard Library is not implemented using Copy-on-Write, provide:
    Improved per-object size
    Improved performance on assignment / copy construction
    Reduced memory usage for duplicated strings

While these classes can be used directly and even mixed in the same application, it is generally recommended that you use the RWCString and RWWString aliases in your application. Whether RWCString is an alias for RWStandardCString or RWCopyOnWriteCString (and similarly for RWWString) is determined when building the Essential Tools Module Library. If the needs of your application change, you can rebuild SourcePro specifying a different implementation. See Section 3.6.1.1, "RWCString and RWWString Implementation," in Installing and Building Your SourcePro C++ Products for more details.

As a general rule of thumb, if RWCString/RWWString objects are being copied often but modified rarely, RWCopyOnWriteCString/RWCopyOnWriteWString will likely yield improved performance. Otherwise RWStandardCString/RWStandardWString should be preferred in order to take advantage of implementation-specific optimizations. Ultimately, the right choice is whichever implementation provides the best performance and system resource trade-offs for your application.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.