String.Empty vs ""

About Monkey 2 Forums General Discussion String.Empty vs ""

This topic contains 1 reply, has 2 voices, and was last updated by  Mark Sibly 2 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5003

    nerobot
    Participant

    Q: About empty strings.

    We can use empty string in two ways

    where

    What way is better or both are equals? First one create str every time, but second one don’t.

    C# string has const named Empty.

    #5035

    Mark Sibly
    Keymaster

    There is special case handling for empty strings in mx2 which means no allocation occurs, so initializing a string to empty works pretty much the same no matter how you do it, eg: Local t:String=Null; Local t:String=””; Local t:String.

    Initializing from an existing string will probably be a teeny, tiny bit slower, as there’s an extra ‘read’ in there, but not so much slower that you should avoid it if it makes things clearer/tidier.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.