From: Jay Freeman (saurik) Date: Tue, 5 Jun 2012 10:21:23 +0000 (-0700) Subject: Avoid deep replace when lifting for-in assignments. X-Git-Tag: v0.9.456~31 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/127c1a9c2cef616211a88e16343614fee9f3b664 Avoid deep replace when lifting for-in assignments. --- diff --git a/Replace.cpp b/Replace.cpp index 2caa728..9a27171 100644 --- a/Replace.cpp +++ b/Replace.cpp @@ -198,7 +198,10 @@ CYStatement *CYContinue::Replace(CYContext &context) { CYAssignment *CYDeclaration::Assignment(CYContext &context) { if (initialiser_ == NULL) return NULL; - return $ CYAssign(Variable(context), initialiser_); + + CYAssignment *value($ CYAssign(Variable(context), initialiser_)); + initialiser_ = NULL; + return value; } CYVariable *CYDeclaration::Variable(CYContext &context) { @@ -319,18 +322,15 @@ CYCompound *CYForDeclarations::Replace(CYContext &context) { // XXX: this still feels highly suboptimal CYStatement *CYForIn::Replace(CYContext &context) { - CYForInInitialiser *initialiser(initialiser_); - - context.Replace(initialiser_); - context.Replace(set_); - context.Replace(code_); - - if (CYAssignment *assignment = initialiser->Assignment(context)) + if (CYAssignment *assignment = initialiser_->Assignment(context)) return $ CYBlock($$->* $E(assignment)->* this ); + context.Replace(initialiser_); + context.Replace(set_); + context.Replace(code_); return this; }