GValue: Add interned string support

This adds support to be able to explicitely stored interned strings into
G_TYPE_STRING GValue.

This is useful for cases where the user:
* *knows* the string to be stored in the GValue is canonical
* Wants to know whther the string stored is canonical

This allows:
* zero-cost GValue copy (the content is guaranteed to be unique and exist
  throughout the process life)
* zero-cost string equality checks (if both string GValue are interned, you just
  need to check the pointers for equality or not, instead of doing a strcmp).

Fixes #2109
This commit is contained in:
Edward Hervey
2020-05-15 07:38:30 +02:00
committed by Edward Hervey
parent c964749de6
commit 1a95ce84ed
5 changed files with 99 additions and 0 deletions

View File

@@ -175,6 +175,16 @@ void g_value_register_transform_func (GType src_type,
*/
#define G_VALUE_NOCOPY_CONTENTS (1 << 27)
/**
* G_VALUE_INTERNED_STRING:
*
* For string values, indicates that the string contained is canonical and will
* exist for the duration of the process. See g_value_set_interned_string().
*
* Since: 2.66
*/
#define G_VALUE_INTERNED_STRING (1 << 28) GLIB_AVAILABLE_MACRO_IN_2_66
/**
* G_VALUE_INIT:
*