From fd840536afb4ff874ca0b9ac9aed775453d5f477 Mon Sep 17 00:00:00 2001 From: Bike Date: Sat, 7 Dec 2024 00:08:42 -0500 Subject: [PATCH] make weak_key_hash_table_pairs into a member function --- include/clasp/gctools/gcweak.h | 3 +-- src/core/hashTable.cc | 3 +-- src/gctools/gcweak.cc | 13 ++++++------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/clasp/gctools/gcweak.h b/include/clasp/gctools/gcweak.h index 2067947c8d..45c00676d8 100644 --- a/include/clasp/gctools/gcweak.h +++ b/include/clasp/gctools/gcweak.h @@ -310,10 +310,9 @@ class WeakKeyHashTable { void maphashFn(core::T_sp fn); bool remhash(core::T_sp tkey); void clrhash(); + core::Vector_sp pairs() const; }; -core::Vector_sp weak_key_hash_table_pairs(const gctools::WeakKeyHashTable& ht); - // ====================================================================== // ---------------------------------------------------------------------- diff --git a/src/core/hashTable.cc b/src/core/hashTable.cc index 7051a583e0..366fb6f8e7 100644 --- a/src/core/hashTable.cc +++ b/src/core/hashTable.cc @@ -210,8 +210,7 @@ CL_DEFUN Vector_sp core__hash_table_pairs(HashTableBase_sp hash_table_base) { return keyvalues; } else if (gc::IsA(hash_table_base)) { WeakKeyHashTable_sp hash_table = gc::As_unsafe(hash_table_base); - gctools::WeakKeyHashTable& wkht = hash_table->_HashTable; - return gctools::weak_key_hash_table_pairs(wkht); + return hash_table->_HashTable.pairs(); } TYPE_ERROR(hash_table_base, Cons_O::createList(cl::_sym_or, cl::_sym_HashTable_O, core::_sym_WeakKeyHashTable_O)); } diff --git a/src/gctools/gcweak.cc b/src/gctools/gcweak.cc index 3bac0228dc..36ea7c145a 100644 --- a/src/gctools/gcweak.cc +++ b/src/gctools/gcweak.cc @@ -347,15 +347,14 @@ void WeakKeyHashTable::clrhash() { }); }; -DOCGROUP(clasp); -CL_DEFUN core::Vector_sp weak_key_hash_table_pairs(const gctools::WeakKeyHashTable& ht) { - size_t len = (*ht._Keys).length(); +core::Vector_sp WeakKeyHashTable::pairs() const { + size_t len = (*_Keys).length(); core::ComplexVector_T_sp keyvalues = core::ComplexVector_T_O::make(len * 2, nil(), core::make_fixnum(0)); - HT_READ_LOCK(&ht); + HT_READ_LOCK(this); for (size_t i(0); i < len; ++i) { - if ((*ht._Keys)[i].raw_() && !(*ht._Keys)[i].unboundp() && !(*ht._Keys)[i].deletedp()) { - keyvalues->vectorPushExtend((*ht._Keys)[i], 16); - keyvalues->vectorPushExtend((*ht._Values)[i], 16); + if ((*_Keys)[i].raw_() && !(*_Keys)[i].unboundp() && !(*_Keys)[i].deletedp()) { + keyvalues->vectorPushExtend((*_Keys)[i], 16); + keyvalues->vectorPushExtend((*_Values)[i], 16); } } return keyvalues;