Remove unnecessary sequence interface on PycDict
This commit is contained in:
@@ -65,7 +65,7 @@ bool PycDict::isEqual(PycRef<PycObject> obj) const
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
PycRef<PycDict> dictObj = obj.cast<PycDict>();
|
PycRef<PycDict> dictObj = obj.cast<PycDict>();
|
||||||
if (m_size != dictObj->m_size)
|
if (m_keys.size() != dictObj->m_keys.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto ki1 = m_keys.cbegin();
|
auto ki1 = m_keys.cbegin();
|
||||||
@@ -85,28 +85,3 @@ bool PycDict::isEqual(PycRef<PycObject> obj) const
|
|||||||
}
|
}
|
||||||
return true;
|
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;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -46,32 +46,29 @@ public:
|
|||||||
PycList(int type = TYPE_LIST) : PycSimpleSequence(type) { }
|
PycList(int type = TYPE_LIST) : PycSimpleSequence(type) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class PycDict : public PycSequence {
|
|
||||||
public:
|
|
||||||
typedef std::vector<PycRef<PycObject>> key_t;
|
|
||||||
typedef std::vector<PycRef<PycObject>> value_t;
|
|
||||||
|
|
||||||
PycDict(int type = TYPE_DICT) : PycSequence(type) { }
|
|
||||||
|
|
||||||
bool isEqual(PycRef<PycObject> obj) const override;
|
|
||||||
|
|
||||||
void load(class PycData* stream, class PycModule* mod) override;
|
|
||||||
|
|
||||||
PycRef<PycObject> get(PycRef<PycObject> key) const;
|
|
||||||
const key_t& keys() const { return m_keys; }
|
|
||||||
const value_t& values() const { return m_values; }
|
|
||||||
|
|
||||||
PycRef<PycObject> get(int idx) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
key_t m_keys;
|
|
||||||
value_t m_values;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PycSet : public PycSimpleSequence {
|
class PycSet : public PycSimpleSequence {
|
||||||
public:
|
public:
|
||||||
typedef PycSimpleSequence::value_t value_t;
|
typedef PycSimpleSequence::value_t value_t;
|
||||||
PycSet(int type = TYPE_SET) : PycSimpleSequence(type) { }
|
PycSet(int type = TYPE_SET) : PycSimpleSequence(type) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PycDict : public PycObject {
|
||||||
|
public:
|
||||||
|
typedef std::vector<PycRef<PycObject>> key_t;
|
||||||
|
typedef std::vector<PycRef<PycObject>> value_t;
|
||||||
|
|
||||||
|
PycDict(int type = TYPE_DICT) : PycObject(type) { }
|
||||||
|
|
||||||
|
bool isEqual(PycRef<PycObject> obj) const override;
|
||||||
|
|
||||||
|
void load(class PycData* stream, class PycModule* mod) override;
|
||||||
|
|
||||||
|
const key_t& keys() const { return m_keys; }
|
||||||
|
const value_t& values() const { return m_values; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
key_t m_keys;
|
||||||
|
value_t m_values;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user