Remove unnecessary sequence interface on PycDict

This commit is contained in:
Michael Hansen
2023-11-09 14:20:15 -08:00
parent 9b384ad1fa
commit e27faa1e88
2 changed files with 20 additions and 48 deletions

View File

@@ -65,7 +65,7 @@ bool PycDict::isEqual(PycRef<PycObject> obj) const
return false;
PycRef<PycDict> dictObj = obj.cast<PycDict>();
if (m_size != dictObj->m_size)
if (m_keys.size() != dictObj->m_keys.size())
return false;
auto ki1 = m_keys.cbegin();
@@ -85,28 +85,3 @@ bool PycDict::isEqual(PycRef<PycObject> obj) const
}
return true;
}
PycRef<PycObject> PycDict::get(PycRef<PycObject> key) const
{
auto ki = m_keys.cbegin();
auto vi = m_values.cbegin();
while (ki != m_keys.cend()) {
if ((*ki)->isEqual(key))
return *vi;
++ki, ++vi;
}
return NULL; // Disassembly shouldn't get non-existent keys
}
PycRef<PycObject> PycDict::get(int idx) const
{
if (idx < 0)
throw std::out_of_range("Dict index out of range");
auto it = m_values.cbegin();
while (idx-- && it != m_values.cend())
++it;
if (it == m_values.cend())
throw std::out_of_range("Dict index out of range");
return *it;
}