[webkit-dev] the name "AtomicString"

Geoffrey Garen ggaren at apple.com
Thu Dec 20 11:24:27 PST 2018


>>> So hard to pronounce though! Why not UniqueString? It’s not quite as explicit but close enough. 
>> 
>> Wouldn’t it be confusing to use UniqueString type for a string that is *common* in order to save memory?
> 
> I would interpret it as UniqueString(foo) means “give me the unique copy of string foo”. You use a unique copy so you can use the same string in many places without wasting memory, or excess time on string compares. It’s used in many places, but there is only one. (Maybe we should call it HighlanderString? OK, not serious.)

By definition, any string that has been uniqued is unique.

So, maybe we like “unique” or maybe we don’t. But if we like “unique”, it’s strictly better than “uniqued”.

>> Personally, I like the AtomString proposal as it is close to the naming we are used to and addresses the issue raised (atomic has a different meaning with threading).
>> Also, I had never heard of interned strings before.

AtomicString has two features:

(1) You do comparison by pointer / object identity;

(2) You never allocate two objects for the same sequence of characters.

JavaScript symbols offer (1) but avoid (2):

	let a = Symbol(“The string of the past!”);
	let b = Symbol(“The string of the past!”);
	a == b; // false
	a === b; // false

Today we call (1) “UniquedStringImpl” and (1) + (2) “AtomicStringImpl”.

If we rename (1) + (2) to “UniqueString” or “UniquedString”, we need a new name for (1) alone.

Geoff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20181220/eabcbc1a/attachment.html>


More information about the webkit-dev mailing list