On Mon, Jun 27, 2011 at 3:46 PM, [email protected]
<[email protected]> wrote:
> Thanks, that clarifies a few things in my mind.
>
> So then it should be trivial for the engine to remove duplication of
> identical string literals.

That is right, string literals are canonicalized so that they have the
same backing store.  In the source code such strings are called
symbols.

But if you make a string eg. with the '+' operator then it will
normally be a new copy even if it contains the same characters as a
string literal or another string.

>
> Stuart.
>
> On Jun 27, 4:30 am, Stephan Beal <[email protected]> wrote:
>> On Jun 26, 4:19 am, "[email protected]"
>>
>> <[email protected]> wrote:
>> > Specifically, if I assign identical string literals to many variables,
>> > do all those variables reference the same string instance?
>>
>> > I assume yes and that modification of one of those variable triggers a
>> > copy (except when the method creates a new string anyway)?
>>
>> Strings are immutable in v8, so you can't modify them, making copy-on-
>> write unnecessary.
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
>



-- 
Erik Corry, Software Engineer
Google Denmark ApS - Frederiksborggade 20B, 1 sal,
1360 København K - Denmark - CVR nr. 28 86 69 84

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to