From 8b095b454b34e88c04592be6c651153f802eced6 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 3 Aug 2009 15:49:40 -0700 Subject: Add update_visitor::replace I noticed that most uses of update_visitor::require() were simply writing the value back to the same place, i.e. foo = require(foo). The new replace() method just encapsulates that paradigm, so we don't have the duplication between the LHS and RHS. * staptree.h (update_visitor::replace): New. * elaborate.cxx, staptree.cxx, tapset-mark.cxx, tapset-perfmon.cxx, tapset-procfs.cxx, tapset-utrace.cxx, tapsets.cxx: Update all require calls that are simply updating the value in-place. --- staptree.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'staptree.h') diff --git a/staptree.h b/staptree.h index bc479559..c9b2bdce 100644 --- a/staptree.h +++ b/staptree.h @@ -874,6 +874,11 @@ struct update_visitor: public visitor targets.push(static_cast(src)); } + template void replace (T*& src, bool clearok=false) + { + src = require(src, clearok); + } + virtual ~update_visitor() { assert(targets.empty()); } virtual void visit_block (block *s); -- cgit