insert_const


Description:

public unowned string insert_const (string str)

Adds a copy of string to the StringChunk, unless the same string has already been added to the StringChunk with insert_const.

This function is useful if you need to copy a large number of strings but do not want to waste space storing duplicates. But you must remember that there may be several pointers to the same string, and so any changes made to the strings should be done very carefully.

Note that insert_const will not return a pointer to a string added with insert, even if they do match.

Parameters:

this

a StringChunk

string

the string to add

Returns:

a pointer to the new or existing copy of string within the StringChunk