minor: optimizing the splice a little more for code generation

This commit is contained in:
Danny Yoo 2012-02-27 14:39:40 -05:00
parent b1a09f3e9d
commit 40b616e9ea

View File

@ -588,10 +588,19 @@ EOF
(format "M.e.length-=~a;" (format "M.e.length-=~a;"
(assemble-oparg (PopEnvironment-n stmt) blockht))])] (assemble-oparg (PopEnvironment-n stmt) blockht))])]
[else [else
(format "M.e.splice(M.e.length-(~a+~a),~a);" (define skip (PopEnvironment-skip stmt))
(assemble-oparg (PopEnvironment-skip stmt) blockht) (define n (PopEnvironment-n stmt))
(assemble-oparg (PopEnvironment-n stmt) blockht) (cond
(assemble-oparg (PopEnvironment-n stmt) blockht))]))] [(and (Const? skip) (Const? n))
(format "M.e.splice(M.e.length-~a,~a);"
(+ (ensure-natural (Const-const skip))
(ensure-natural (Const-const n)))
(Const-const n))]
[else
(format "M.e.splice(M.e.length-(~a+~a),~a);"
(assemble-oparg skip blockht)
(assemble-oparg n blockht)
(assemble-oparg n blockht))])]))]
[(PushImmediateOntoEnvironment? stmt) [(PushImmediateOntoEnvironment? stmt)
(format "M.e.push(~a);" (format "M.e.push(~a);"