Added comment

This commit is contained in:
Sandip Patel 2019-09-09 13:56:35 +05:30
parent cde18342da
commit 5ce9f8c8de

View file

@ -278,6 +278,17 @@ namespace graphene { namespace chain {
*/ */
class account_member_index : public secondary_index class account_member_index : public secondary_index
{ {
/* std::less::operator() is less efficient so using key_compare here.
* Let assume that it has two keys key1 and key2 and we want to insert key3.
* the insert function needs to first call std::less::operator() with key1 and key3.
* Assume std::less::operator()(key1, key3) returns false.
* It has to call std::less::operator() again with the keys switched,
* std::less::operator()(key3, key1), to decide whether key1 is equal to key3 or
* key3 is greater than key1. There are two calls to std::less::operator() to make
* a decision if the first call returns false.
* std::map::insert and std::set used key_compare,
* there would be sufficient information to make the right decision using just one call.
*/
class key_compare { class key_compare {
public: public:
inline bool operator()( const public_key_type& a, const public_key_type& b )const inline bool operator()( const public_key_type& a, const public_key_type& b )const