Data Structures | Functions | Variables
Stringshare

C++ Binding to Eina_Stringshare. More...

Data Structures

struct  efl::eina::steal_stringshare_ref_t
 Type for stealing the ownership of a string that was previously shared. More...
 
struct  efl::eina::stringshare
 Stringshare class. More...
 
struct  efl::eina::is_contiguous_iterator< stringshare::const_iterator >
 Specialization of the default template to define the stringshare::const_iterator as a contiguous iterator. More...
 

Functions

bool efl::eina::operator== (stringshare const &lhs, stringshare const &rhs)
 Check if two eina::stringshare objects represent the same string. More...
 
bool efl::eina::operator!= (stringshare const &lhs, stringshare const &rhs)
 Check if two eina::stringshare objects represent different strings. More...
 
bool efl::eina::operator== (stringshare const &lhs, const char *rhs)
 Compare an eina::stringshare object with a c-like string. More...
 
bool efl::eina::operator!= (stringshare const &lhs, const char *rhs)
 Compare an eina::stringshare object with a c-like string. More...
 
bool efl::eina::operator== (const char *lhs, stringshare const &rhs)
 Compare an eina::stringshare object with a c-like string. More...
 
bool efl::eina::operator!= (const char *lhs, stringshare const &rhs)
 Compare an eina::stringshare object with a c-like string. More...
 

Variables

steal_stringshare_ref_t const efl::eina::steal_stringshare_ref = {}
 Constant instance of steal_stringshare_ref_t for quick reference.
 

Detailed Description

C++ Binding to Eina_Stringshare.

This class allows you to store a single copy of a string, and use in multiple places throughout your program.

This is a method to reduce the number of duplicated strings kept in memory. It's pretty common for the same strings to be dynamically allocated repeatedly between applications and libraries, especially in circumstances where you could have multiple copies of a structure that allocates the string. So rather than duplicating and freeing these strings, you request a read-only pointer to an existing string and only incur the overhead of a hash look-up.

It sounds like micro-optimizing, but profiling has shown this can have a significant impact as you scale the number of copies up. It improves string creation/destruction speed, reduces memory use and decreases memory fragmentation, so a win all-around.

Function Documentation

§ operator==() [1/3]

bool efl::eina::operator== ( stringshare const &  lhs,
stringshare const &  rhs 
)
inline

Check if two eina::stringshare objects represent the same string.

Returns
true if the strings of the objects are equal, false otherwise.

This operator checks if two eina::stringshare objects represent the same string. Because of the nature of the objects, this operation falls into a simple pointer comparison, since identical strings are represented by the same instance.

References efl::eina::stringshare::c_str().

§ operator!=() [1/3]

bool efl::eina::operator!= ( stringshare const &  lhs,
stringshare const &  rhs 
)
inline

Check if two eina::stringshare objects represent different strings.

Returns
true if the strings of the objects are different, false otherwise.

This function essentially returns the opposite of operator==(stringshare const& lhs, stringshare const& rhs).

§ operator==() [2/3]

bool efl::eina::operator== ( stringshare const &  lhs,
const char *  rhs 
)
inline

Compare an eina::stringshare object with a c-like string.

Returns
true if the content of the eina::stringshare string is equal the content of the given string, false otherwise.

References efl::eina::stringshare::c_str().

§ operator!=() [2/3]

bool efl::eina::operator!= ( stringshare const &  lhs,
const char *  rhs 
)
inline

Compare an eina::stringshare object with a c-like string.

Returns
true if the content of the eina::stringshare string is different from content of the given string, false otherwise.

§ operator==() [3/3]

bool efl::eina::operator== ( const char *  lhs,
stringshare const &  rhs 
)
inline

Compare an eina::stringshare object with a c-like string.

Returns
true if the content of the eina::stringshare string is equal the content of the given string, false otherwise.

§ operator!=() [3/3]

bool efl::eina::operator!= ( const char *  lhs,
stringshare const &  rhs 
)
inline

Compare an eina::stringshare object with a c-like string.

Returns
true if the content of the eina::stringshare string is different from content of the given string, false otherwise.