title: Reference to a dictionary value to reduce lookups
body: <p>If I an have unordered_map <code>std::unordered_map&lt;int, myClass&gt; dic;</code> and I want to do a lot of assignments to a given element, would it be a good practice to use a reference to the object, so that I just search the dictionary once?. That is:</p>
  <pre><code>myClass&amp; ref= dic[mykey];
  ref.myval0=0;
  ref.myval1=0;
  ref.myval2=0;
  ref.myval3=0;
  </code></pre>
  <p>instead of simply</p>
  <pre><code>dic[mykey].myval0=0;
  dic[mykey].myval1=0;
  dic[mykey].myval2=0;
  dic[mykey].myval3=0;
  </code></pre>