[gjs: 7/25] js: Remove hashtable init() calls



commit 88d01bf33a76d245b6cb70b83ff66b7ae121b2e4
Author: Philip Chimento <philip chimento gmail com>
Date:   Sat May 18 23:54:04 2019 -0700

    js: Remove hashtable init() calls
    
    JS::GCHashMap and JS::GCHashSet no longer need to have their init()
    method called before using them. In the case where init() wasn't
    reserving a particular amount of space, it can just be removed. In the
    case where it was, it must be replaced by a call to reserve().

 gi/boxed.cpp    | 2 +-
 gi/object.cpp   | 8 --------
 gi/object.h     | 1 -
 gjs/context.cpp | 5 -----
 4 files changed, 1 insertion(+), 15 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 97df571d..909cf549 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -134,7 +134,7 @@ BoxedPrototype::FieldMap* BoxedPrototype::create_field_map(
 
     auto* result = new BoxedPrototype::FieldMap();
     n_fields = g_struct_info_get_n_fields(struct_info);
-    if (!result->init(n_fields)) {
+    if (!result->reserve(n_fields)) {
         JS_ReportOutOfMemory(cx);
         return nullptr;
     }
diff --git a/gi/object.cpp b/gi/object.cpp
index 035d66eb..c8560205 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1286,14 +1286,6 @@ ObjectPrototype::ObjectPrototype(GIObjectInfo* info, GType gtype)
     GJS_INC_COUNTER(object_prototype);
 }
 
-bool ObjectPrototype::init(JSContext* cx) {
-    if (!m_property_cache.init() || !m_field_cache.init()) {
-        JS_ReportOutOfMemory(cx);
-        return false;
-    }
-    return true;
-}
-
 /*
  * ObjectInstance::update_heap_wrapper_weak_pointers:
  *
diff --git a/gi/object.h b/gi/object.h
index 0935551b..1ba36f9d 100644
--- a/gi/object.h
+++ b/gi/object.h
@@ -207,7 +207,6 @@ class ObjectPrototype
     FieldCache m_field_cache;
 
     ObjectPrototype(GIObjectInfo* info, GType gtype);
-    GJS_JSAPI_RETURN_CONVENTION bool init(JSContext* cx);
     ~ObjectPrototype();
 
     static constexpr InfoType::Tag info_type_tag = InfoType::Object;
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 481ec1ac..52e39b97 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -473,12 +473,7 @@ GjsContextPrivate::GjsContextPrivate(JSContext* cx, GjsContext* public_context)
 
     JSRuntime* rt = JS_GetRuntime(m_cx);
     m_fundamental_table = new JS::WeakCache<FundamentalTable>(rt);
-    if (!m_fundamental_table->init())
-        g_error("Failed to initialize fundamental objects table");
-
     m_gtype_table = new JS::WeakCache<GTypeTable>(rt);
-    if (!m_gtype_table->init())
-        g_error("Failed to initialize GType objects table");
 
     m_atoms = new GjsAtoms();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]