From c1c5bb9a8bd0a58f98708f949e4dbe74561898a7 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 25 Aug 2009 18:20:39 -0700 Subject: Avoid needless Dwarf_Die copying * dwflpp.cxx (dwflpp::iterate_over_cus): Use the Dwarf_Die as a pointer directly into the vector. (dwflpp::iterate_over_inline_instances): Ditto. (dwflpp::iterate_over_functions): Ditto in a map. --- dwflpp.cxx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/dwflpp.cxx b/dwflpp.cxx index 7d4fa3ab..436ee88f 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -480,12 +480,11 @@ dwflpp::iterate_over_cus (int (*callback)(Dwarf_Die * die, void * arg), } } - for (unsigned i = 0; i < v->size(); i++) + for (vector::iterator i = v->begin(); i != v->end(); ++i) { - if (pending_interrupts) return; - Dwarf_Die die = v->at(i); - int rc = (*callback)(& die, data); - if (rc != DWARF_CB_OK) break; + int rc = (*callback)(&*i, data); + if (rc != DWARF_CB_OK || pending_interrupts) + break; } } @@ -522,12 +521,11 @@ dwflpp::iterate_over_inline_instances (int (* callback)(Dwarf_Die * die, void * dwarf_func_inline_instances (function, cu_inl_function_caching_callback, v); } - for (unsigned i=0; isize(); i++) + for (vector::iterator i = v->begin(); i != v->end(); ++i) { - if (pending_interrupts) return; - Dwarf_Die die = v->at(i); - int rc = (*callback)(& die, data); - if (rc != DWARF_CB_OK) break; + int rc = (*callback)(&*i, data); + if (rc != DWARF_CB_OK || pending_interrupts) + break; } } @@ -629,7 +627,7 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * } else if (name_has_wildcard (function)) { - for (it = v->begin(); it != v->end(); it++) + for (it = v->begin(); it != v->end(); ++it) { if (pending_interrupts) return DWARF_CB_ABORT; const string& func_name = it->first; @@ -647,10 +645,9 @@ dwflpp::iterate_over_functions (int (* callback)(Dwarf_Die * func, base_query * } else if (has_statement_num) // searching all for kernel.statement { - for (cu_function_cache_t::iterator it = v->begin(); it != v->end(); it++) + for (it = v->begin(); it != v->end(); ++it) { - Dwarf_Die die = it->second; - rc = (*callback)(& die, q); + rc = (*callback)(&it->second, q); if (rc != DWARF_CB_OK) break; } } -- cgit