Browse Source

refactor `LIST_APPEND`

blueloveTH 3 years ago
parent
commit
24c2563315
2 changed files with 3 additions and 10 deletions
  1. 3 4
      src/ceval.h
  2. 0 6
      src/frame.h

+ 3 - 4
src/ceval.h

@@ -86,10 +86,9 @@ PyVar VM::run_frame(Frame* frame){
         } continue;
         case OP_LOAD_EVAL_FN: frame->push(builtins->attr(m_eval)); continue;
         case OP_LIST_APPEND: {
-            pkpy::Args args(2);
-            args[1] = frame->pop_value(this);            // obj
-            args[0] = frame->top_value_offset(this, -2);     // list
-            fast_call(m_append, std::move(args));
+            PyVar obj = frame->pop_value(this);
+            pkpy::List& list = PyList_AS_C(frame->top_1());
+            list.push_back(std::move(obj));
         } continue;
         case OP_BUILD_CLASS: {
             const Str& clsName = frame->co->names[byte.arg].first;

+ 0 - 6
src/frame.h

@@ -89,12 +89,6 @@ struct Frame {
         return _data[_data.size()-2];
     }
 
-    inline PyVar top_value_offset(VM* vm, int n){
-        PyVar value = _data[_data.size() + n];
-        try_deref(vm, value);
-        return value;
-    }
-
     template<typename T>
     inline void push(T&& obj){ _data.push_back(std::forward<T>(obj)); }