[Webkit-unassigned] [Bug 31330] Expose dtoa() for ECMA-262

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Nov 18 10:55:57 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=31330


Darin Adler <darin at apple.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #43340|review?                     |review+
               Flag|                            |




--- Comment #9 from Darin Adler <darin at apple.com>  2009-11-18 10:55:57 PST ---
(From update of attachment 43340)
> +    UChar* d;
> +    if (!allocChars(length).getValue(d))
> +        return &UString::Rep::null();
> +    else {
> +        for (unsigned i = 0; i < length; i++)
> +            d[i] = static_cast<unsigned char>(c[i]); // use unsigned char to zero-extend instead of sign-extend
> +        return UString::Rep::create(d, static_cast<int>(length));
> +    }
> +
> +}

Normally we do early return, not else after return. There's also an extra blank
line here.

Is the static_cast<int> really needed?

I suggest marking this createRep function, which is used in only one place,
inline.

>          UString();
> +        // Constructor for null-terminated ASCII string.
>          UString(const char*);
> +        // Constructor for non-null-terminated ASCII string.
> +        UString(const char*, unsigned length);
>          UString(const UChar*, int length);
>          UString(UChar*, int length, bool copy);

Given that the other constructors take int for length, why did you chose
unsigned? If this was a new class, I would probably use size_t or perhaps
unsigned, but typically we just keep new consistent with old, locally.

> +    // dtoa() for ECMA-262 'ToString Applied to the Number Type.'
> +    // The *resultLength will have the length of the resultant string in bufer.
> +    // The resultant string isn't terminated by 0.
> +    void doubleToStringInJavaScriptFormat(double, DtoaBuffer buffer, unsigned* resultLength);
>  } // namespace WTF

Probably would be slightly nicer to have a blank line before the closing brace.
Could omit the name "buffer" since the type name already says that.

r=me

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list