# # # patch "ChangeLog" # from [338cd661b8c3431393b92e155ca8795f532de858] # to [dc0b8ff84fc1beb10311b52aa6be9db96f405f37] # # patch "merkle_tree.cc" # from [0e353f8460c079b618906210fb3abb23fc550944] # to [0be64fcc156d10e75e0f235856e9c4c428f1915c] # ============================================================ --- ChangeLog 338cd661b8c3431393b92e155ca8795f532de858 +++ ChangeLog dc0b8ff84fc1beb10311b52aa6be9db96f405f37 @@ -1,3 +1,9 @@ +2006-05-12 Matt Johnston + + * merkle_tree.cc (bitset_to_prefix): use strings directly + rather than ostringstream for getting bitset blocks, ~10% + cpu time improvement for empty pull. + 2006-05-12 Graydon Hoare * xdelta.cc (apply_delta): Tolerate 0-length instructions. ============================================================ --- merkle_tree.cc 0e353f8460c079b618906210fb3abb23fc550944 +++ merkle_tree.cc 0be64fcc156d10e75e0f235856e9c4c428f1915c @@ -23,6 +23,15 @@ using boost::dynamic_bitset; using namespace std; +static void +bitset_to_prefix(dynamic_bitset const & pref, + prefix & rawpref) +{ + string s(pref.num_blocks(), 0x00); + to_block_range(pref, s.begin()); + rawpref = prefix(s); +} + void netcmd_item_type_to_string(netcmd_item_type t, string & typestr) { @@ -97,9 +106,7 @@ merkle_node::get_raw_prefix(prefix & pref) const { check_invariants(); - ostringstream oss; - to_block_range(this->pref, ostream_iterator(oss)); - pref = prefix(oss.str()); + bitset_to_prefix(this->pref, pref); } void @@ -159,9 +166,7 @@ { dynamic_bitset ext; extended_prefix(slot, ext); - ostringstream oss; - to_block_range(ext, ostream_iterator(oss)); - extended = prefix(oss.str()); + bitset_to_prefix(ext, extended); } void @@ -423,9 +428,8 @@ { pick_slot_and_prefix_for_value(val, l, slotnum, pref); - ostringstream oss; - to_block_range(pref, ostream_iterator(oss)); - prefix rawpref(oss.str()); + prefix rawpref; + bitset_to_prefix(pref, rawpref); merkle_table::const_iterator i = table.find(make_pair(rawpref, l)); if (i == table.end() || @@ -462,9 +466,8 @@ dynamic_bitset pref; pick_slot_and_prefix_for_value(leaf, level, slotnum, pref); - ostringstream oss; - to_block_range(pref, ostream_iterator(oss)); - prefix rawpref(oss.str()); + prefix rawpref; + bitset_to_prefix(pref, rawpref); merkle_table::const_iterator i = tab.find(make_pair(rawpref, level)); merkle_ptr node;