From 5a386c6f89edf011820d60636d16f035ee3a66b0 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Thu, 26 Apr 2018 18:41:30 +0200 Subject: [PATCH] Bug 912079 part 4 - Optimize SuppressDeletedPropertyHelper when the property matches the iterator's previous one. r=anba --HG-- extra : rebase_source : 7c860b0162c165f536e5b316204ea76eebaff59d --- js/src/vm/Iteration.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/src/vm/Iteration.cpp b/js/src/vm/Iteration.cpp index 6bd8788cbaeb..d6ded773c569 100644 --- a/js/src/vm/Iteration.cpp +++ b/js/src/vm/Iteration.cpp @@ -1205,6 +1205,17 @@ SuppressDeletedProperty(JSContext* cx, NativeIterator* ni, HandleObject obj, if (ni->obj != obj) return true; + // Optimization for the following common case: + // + // for (var p in o) { + // delete o[p]; + // } + // + // Note that usually both strings will be atoms so we only check for pointer + // equality here. + if (ni->props_cursor > ni->begin() && ni->props_cursor[-1] == str) + return true; + while (true) { bool restart = false;