瀏覽代碼

improve list.append

blueloveTH 3 年之前
父節點
當前提交
3cc481c50e
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      src/vm.h

+ 5 - 4
src/vm.h

@@ -118,12 +118,13 @@ private:
                 frame->push(PyStr(ss.str()));
                 frame->push(PyStr(ss.str()));
             } break;
             } break;
             case OP_LOAD_EVAL_FN: {
             case OP_LOAD_EVAL_FN: {
-                frame->push(builtins->attribs["eval"]);
+                frame->push(builtins->attribs["eval"_c]);
             } break;
             } break;
             case OP_LIST_APPEND: {
             case OP_LIST_APPEND: {
-                PyVar obj = frame->popValue(this);
-                PyVar list = frame->__topValueN(this, -2);
-                fastCall(list, "append", {list, obj});
+                pkpy::ArgList args(2);
+                args[1] = frame->popValue(this);            // obj
+                args[0] = frame->__topValueN(this, -2);     // list
+                fastCall(args[0], "append"_c, std::move(args));
             } break;
             } break;
             case OP_STORE_FUNCTION:
             case OP_STORE_FUNCTION:
                 {
                 {