Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1739)

Unified Diff: src/utils.h

Issue 14422: Introduced a TempAssign utility because I just couldn't watch this anymore. Y... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codegen-ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
===================================================================
--- src/utils.h (revision 958)
+++ src/utils.h (working copy)
@@ -372,6 +372,23 @@
};
+// A temporary assignment sets a (non-local) variable to a value on
+// construction and resets it the value on destruction.
Mads Ager (chromium) 2008/12/15 08:36:30 it the -> the
+template <typename T>
+class TempAssign {
+ public:
+ TempAssign(T* var, T value): var_(var), old_value_(*var) {
+ *var = value;
+ }
+
+ ~TempAssign() { *var_ = old_value_; }
+
+ private:
+ T* var_;
+ T old_value_;
+};
+
+
template <typename T, int kSize>
class EmbeddedVector : public Vector<T> {
public:
« no previous file with comments | « src/codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698