Unexpected performance results

Discussion in 'C++' started by Dave, Apr 8, 2004.

  1. Dave

    Dave Guest

    Hello all,

    Can anybody think of a plausible explanation for why my profiler is telling
    me that I get better performance with map::eek:perator[] than with
    map::insert()?

    Thanks,
    Dave
     
    Dave, Apr 8, 2004
    #1
    1. Advertisements

  2. Dave

    Leor Zolman Guest

    This would be totally a QOI issue, but I did take a look just for grins in
    an implementation or two, and I noticed that, even though operator[] tends
    to call insert() to do its work, insert() returns a pair<...> by value
    while operator[] just returns a ref to an element. Perhaps the construction
    of that return value from insert() might be your culprit...
    -leor
     
    Leor Zolman, Apr 8, 2004
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.