src/share/vm/oops/symbol.cpp

changeset 4267
bd7a7ce2e264
parent 4037
da91efe96a93
child 4531
fcc9e7681d63
     1.1 --- a/src/share/vm/oops/symbol.cpp	Fri Nov 09 08:36:17 2012 -0800
     1.2 +++ b/src/share/vm/oops/symbol.cpp	Mon Nov 12 14:03:53 2012 -0800
     1.3 @@ -153,17 +153,15 @@
     1.4  
     1.5  void Symbol::print_symbol_on(outputStream* st) const {
     1.6    st = st ? st : tty;
     1.7 -  int length = UTF8::unicode_length((const char*)bytes(), utf8_length());
     1.8 -  const char *ptr = (const char *)bytes();
     1.9 -  jchar value;
    1.10 -  for (int index = 0; index < length; index++) {
    1.11 -    ptr = UTF8::next(ptr, &value);
    1.12 -    if (value >= 32 && value < 127 || value == '\'' || value == '\\') {
    1.13 -      st->put(value);
    1.14 -    } else {
    1.15 -      st->print("\\u%04x", value);
    1.16 -    }
    1.17 -  }
    1.18 +  st->print("%s", as_quoted_ascii());
    1.19 +}
    1.20 +
    1.21 +char* Symbol::as_quoted_ascii() const {
    1.22 +  const char *ptr = (const char *)&_body[0];
    1.23 +  int quoted_length = UTF8::quoted_ascii_length(ptr, utf8_length());
    1.24 +  char* result = NEW_RESOURCE_ARRAY(char, quoted_length + 1);
    1.25 +  UTF8::as_quoted_ascii(ptr, result, quoted_length + 1);
    1.26 +  return result;
    1.27  }
    1.28  
    1.29  jchar* Symbol::as_unicode(int& length) const {

mercurial