Ignore:
Timestamp:
Nov 18, 2002, 10:53:35 PM (23 years ago)
Author:
darin
Message:
  • property and string improvements giving a 7% or so improvement in JavaScript iBench
  • kjs/property_map.h: Rewrite to use a hash table.
  • kjs/property_map.cpp: Ditto.
  • kjs/string_object.h:
  • kjs/string_object.cpp: (StringInstanceImp::StringInstanceImp): Construct a string with the right value instead of putting the string in later. (StringInstanceImp::get): Get the length from the string, not a separate property. (StringInstanceImp::put): Ignore attempts to set length, since we don't put it in the property map. (StringInstanceImp::hasProperty): Return true for length. (StringInstanceImp::deleteProperty): Return false for length. (StringObjectImp::construct): Call new StringInstanceImp constructor. Don't try to set a length property.
  • kjs/ustring.h: Make the rep deref know how to deallocate the rep.
  • kjs/ustring.cpp: (UString::release): Move the real work to the rep's deref, since the hash table now uses the rep directly.
  • kjs/object.h: Remove unused field.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r1824 r2749  
    4242{
    4343  setInternalValue(String(""));
     44}
     45
     46StringInstanceImp::StringInstanceImp(const Object &proto, const UString &string)
     47  : ObjectImp(proto)
     48{
     49  setInternalValue(String(string));
     50}
     51
     52Value StringInstanceImp::get(ExecState *exec, const UString &propertyName) const
     53{
     54  if (propertyName == lengthPropertyName)
     55    return Number(internalValue().toString(exec).size());
     56  return ObjectImp::get(exec, propertyName);
     57}
     58
     59void StringInstanceImp::put(ExecState *exec, const UString &propertyName, const Value &value, int attr)
     60{
     61  if (propertyName == lengthPropertyName)
     62    return;
     63  ObjectImp::put(exec, propertyName, value, attr);
     64}
     65
     66bool StringInstanceImp::hasProperty(ExecState *exec, const UString &propertyName) const
     67{
     68  if (propertyName == lengthPropertyName)
     69    return true;
     70  return ObjectImp::hasProperty(exec, propertyName);
     71}
     72
     73bool StringInstanceImp::deleteProperty(ExecState *exec, const UString &propertyName)
     74{
     75  if (propertyName == lengthPropertyName)
     76    return false;
     77  return ObjectImp::deleteProperty(exec, propertyName);
    4478}
    4579
     
    517551{
    518552  Object proto = exec->interpreter()->builtinStringPrototype();
    519   Object obj(new StringInstanceImp(proto ));
    520 
    521   UString s;
    522   if (args.size() > 0)
    523     s = args.begin()->dispatchToString(exec);
    524   else
    525     s = UString("");
    526 
    527   obj.setInternalValue(String(s));
    528   obj.put(exec, lengthPropertyName, Number(s.size()), ReadOnly|DontEnum|DontDelete);
    529 
    530   return obj;
     553  if (args.size() == 0)
     554    return Object(new StringInstanceImp(proto));
     555  return Object(new StringInstanceImp(proto, args.begin()->dispatchToString(exec)));
    531556}
    532557
Note: See TracChangeset for help on using the changeset viewer.