Commit 36f960f0 authored by Jason Orendorff's avatar Jason Orendorff
Browse files

Bug 807001 - Change Map and Set size() methods to accessor properties. r=Waldo.

--HG--
extra : rebase_source : bf2809aa1d943caa6349d7b44621cd1b0bb85742
parent 15a89ded
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ VariablesView.prototype = {
   */
  empty: function VV_empty(aTimeout = LAZY_EMPTY_DELAY) {
    // If there are no items in this container, emptying is useless.
    if (!this._store.size()) {
    if (!this._store.size) {
      return;
    }
    // Check if this empty operation may be executed lazily.
@@ -110,7 +110,7 @@ VariablesView.prototype = {
      this._parent.removeChild(prevList);
      this._parent.appendChild(currList);

      if (!this._store.size()) {
      if (!this._store.size) {
        this._appendEmptyNotice();
      }
    }.bind(this), aTimeout);
+3 −3
Original line number Diff line number Diff line
@@ -812,7 +812,7 @@ create({ constructor: GlobalSearchView, proto: MenuContainer.prototype }, {
   */
  _fetchSources: function DVGS__fetchSources(aFetchCallback, aFetchedCallback, aLocations) {
    // If all the sources were already fetched, then don't do anything.
    if (this._cache.size() == aLocations.length) {
    if (this._cache.size == aLocations.length) {
      aFetchedCallback();
      return;
    }
@@ -840,7 +840,7 @@ create({ constructor: GlobalSearchView, proto: MenuContainer.prototype }, {
    this._cache.set(aLocation, aContents);

    // Check if all sources were fetched and stored in the cache.
    if (this._cache.size() == this._sourcesCount) {
    if (this._cache.size == this._sourcesCount) {
      this._onFetchSourcesFinished();
    }
  },
@@ -1151,7 +1151,7 @@ GlobalResults.prototype = {
  /**
   * Gets the number of source results in this store.
   */
  get itemCount() this._store.size(),
  get itemCount() this._store.size,

  _store: null
};
+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ function testLocationChange()
  window.addEventListener("Debugger:GlobalSearch:CacheCleared", function _onCacheCleared(aEvent) {
    window.removeEventListener(aEvent.type, _onCacheCleared);

    is(gSearchView._cache.size(), 0,
    is(gSearchView._cache.size, 0,
      "The scripts sources cache for global searching should be cleared after a page navigation.")

    cacheCleared = true;
+14 −6
Original line number Diff line number Diff line
@@ -947,8 +947,12 @@ Class MapObject::class_ = {
    mark
};

JSPropertySpec MapObject::properties[] = {
    JS_PSG("size", size, 0),
    JS_PS_END
};

JSFunctionSpec MapObject::methods[] = {
    JS_FN("size", size, 0, 0),
    JS_FN("get", get, 1, 0),
    JS_FN("has", has, 1, 0),
    JS_FN("set", set, 2, 0),
@@ -960,7 +964,7 @@ JSFunctionSpec MapObject::methods[] = {

static JSObject *
InitClass(JSContext *cx, Handle<GlobalObject*> global, Class *clasp, JSProtoKey key, Native construct,
          JSFunctionSpec *methods)
          JSPropertySpec *properties, JSFunctionSpec *methods)
{
    Rooted<JSObject*> proto(cx, global->createBlankPrototype(cx, clasp));
    if (!proto)
@@ -970,7 +974,7 @@ InitClass(JSContext *cx, Handle<GlobalObject*> global, Class *clasp, JSProtoKey
    Rooted<JSFunction*> ctor(cx, global->createConstructor(cx, construct, ClassName(key, cx), 1));
    if (!ctor ||
        !LinkConstructorAndPrototype(cx, ctor, proto) ||
        !DefinePropertiesAndBrand(cx, proto, NULL, methods) ||
        !DefinePropertiesAndBrand(cx, proto, properties, methods) ||
        !DefineConstructorAndPrototype(cx, global, key, ctor, proto))
    {
        return NULL;
@@ -982,7 +986,7 @@ JSObject *
MapObject::initClass(JSContext *cx, JSObject *obj)
{
    Rooted<GlobalObject*> global(cx, &obj->asGlobal());
    return InitClass(cx, global, &class_, JSProto_Map, construct, methods);
    return InitClass(cx, global, &class_, JSProto_Map, construct, properties, methods);
}

template <class Range>
@@ -1410,8 +1414,12 @@ Class SetObject::class_ = {
    mark
};

JSPropertySpec SetObject::properties[] = {
    JS_PSG("size", size, 0),
    JS_PS_END
};

JSFunctionSpec SetObject::methods[] = {
    JS_FN("size", size, 0, 0),
    JS_FN("has", has, 1, 0),
    JS_FN("add", add, 1, 0),
    JS_FN("delete", delete_, 1, 0),
@@ -1424,7 +1432,7 @@ JSObject *
SetObject::initClass(JSContext *cx, JSObject *obj)
{
    Rooted<GlobalObject*> global(cx, &obj->asGlobal());
    return InitClass(cx, global, &class_, JSProto_Set, construct, methods);
    return InitClass(cx, global, &class_, JSProto_Set, construct, properties, methods);
}

void
+2 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ class MapObject : public JSObject {
    static JSObject *initClass(JSContext *cx, JSObject *obj);
    static Class class_;
  private:
    static JSPropertySpec properties[];
    static JSFunctionSpec methods[];
    ValueMap *getData() { return static_cast<ValueMap *>(getPrivate()); }
    static ValueMap & extract(CallReceiver call);
@@ -114,6 +115,7 @@ class SetObject : public JSObject {
    static JSObject *initClass(JSContext *cx, JSObject *obj);
    static Class class_;
  private:
    static JSPropertySpec properties[];
    static JSFunctionSpec methods[];
    ValueSet *getData() { return static_cast<ValueSet *>(getPrivate()); }
    static ValueSet & extract(CallReceiver call);
Loading