Use deque instead of set

This commit is contained in:
Akash Munagala
2023-02-13 19:25:45 -08:00
parent 66c46661d9
commit f00921d3d3
2 changed files with 4 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
#include "pyc_module.h"
#include <list>
#include <deque>
/* Similar interface to PycObject, so PycRef can work on it... *
* However, this does *NOT* mean the two are interchangeable! */
@@ -360,7 +361,7 @@ private:
class ASTSet : public ASTNode {
public:
typedef std::set<PycRef<ASTNode>> value_t;
typedef std::deque<PycRef<ASTNode>> value_t;
ASTSet(value_t values)
: ASTNode(NODE_SET), m_values(std::move(values)) { }

View File

@@ -326,7 +326,7 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
{
ASTSet::value_t values;
for (int i=0; i<operand; i++) {
values.insert(stack.top());
values.push_front(stack.top());
stack.pop();
}
stack.push(new ASTSet(values));
@@ -1578,7 +1578,7 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
ASTSet::value_t result = lhs->values();
for (const auto& it : obj.cast<PycSet>()->values()) {
result.insert(new ASTObject(it));
result.push_back(new ASTObject(it));
}
stack.push(new ASTSet(result));