Added more tests, which also caught a bug!
http://codereview.chromium.org/8304021/diff/1/src/api.cc File src/api.cc (right): http://codereview.chromium.org/8304021/diff/1/src/api.cc#newcode3638 src/api.cc:3638: if (str->IsAsciiRepresentation()) { On 2011/10/17 09:40:51, Yang wrote:
IsAsciiRepresentation() is not reliable for cons and slices with
regard to
external strings. For example, when a cons is constructed from two
ascii
strings, and those two ascii strings are then externalized and
converted to
two-byte, the instance type of the cons string still says that it's an
ascii
string, which is what IsAsciiRepresentation() returns. Use IsAsciiRepresentationUnderneath() instead.
I added a test to verify that this is OK. http://codereview.chromium.org/8304021/diff/1/src/objects.cc File src/objects.cc (right): http://codereview.chromium.org/8304021/diff/1/src/objects.cc#newcode5952 src/objects.cc:5952: if (input->IsAsciiRepresentation()) return total + to - from; On 2011/10/17 09:40:51, Yang wrote:
Again, IsAsciiRepresentation() is not reliable.
I think in this case it is exactly what I need. I only need the length in UTF8, which won't change if a string is externalized. http://codereview.chromium.org/8304021/ -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
