boostorg / compute

A C++ GPU Computing Library for OpenCL
http://boostorg.github.io/compute/
Boost Software License 1.0
1.52k stars 333 forks source link

Unwanted function call for std::map::operator[] #866

Open ankurhero opened 3 years ago

ankurhero commented 3 years ago

https://github.com/boostorg/compute/blob/36c89134d4013b2e5e45bc55656a18bd6141995a/include/boost/compute/detail/lru_cache.hpp#L102

Since i is a valid iterator, we can replace this call with. m_map[key] = std::make_pair(value, j);

with

i->second = std::make_pair(value, j);

avoiding the second map search.

chetanpandey1266 commented 1 year ago

I don't think this will work as iterator is not passing to the location corresponding to key but to a random position ( map.end() ).