Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

more speed

You can find videos of Stroustrup explaining why std::multimap is so slow(注記). See Why you shouldn't use set (and what you should use instead) by Matt Austern.

Use Boost.Container for flat_(multi)map which is a mature implementation based on Matt’s article, via Andrei Alexandrescu.

As a drop-in replacement, see what that does for your speed!


multimap.emplace_hint(range.first, std::make_pair(temp.hash, temp.move()));

That can (now) be written much more simply:

multimap.emplace_hint(range.first, { temp.hash, temp.move() } );

if (node->data.value == false)

Testing a bool against true/false is just strange. It is a bool; use it.

if (!node->data.value)

while (node != nullptr)

Don’t explicitly test against nullptr. Use the the truth value of the pointer’s value, which might (in the case of smart pointers) be an efficient operator bool in the class.

while (node)

#addendum

addendum

(注記) A flat map wins for looking things up, which in my experience is the bulk of the run. The tree-based map will start beating flat-map for inserts and deletes at some size n and continue pulling ahead since the k1∙O(log n) is a better order than k2∙O(n) even when k2 is much smaller than k1.

more speed

You can find videos of Stroustrup explaining why std::multimap is so slow(注記). See Why you shouldn't use set (and what you should use instead) by Matt Austern.

Use Boost.Container for flat_(multi)map which is a mature implementation based on Matt’s article, via Andrei Alexandrescu.

As a drop-in replacement, see what that does for your speed!


multimap.emplace_hint(range.first, std::make_pair(temp.hash, temp.move()));

That can (now) be written much more simply:

multimap.emplace_hint(range.first, { temp.hash, temp.move() } );

if (node->data.value == false)

Testing a bool against true/false is just strange. It is a bool; use it.

if (!node->data.value)

while (node != nullptr)

Don’t explicitly test against nullptr. Use the the truth value of the pointer’s value, which might (in the case of smart pointers) be an efficient operator bool in the class.

while (node)

#addendum

(注記) A flat map wins for looking things up, which in my experience is the bulk of the run. The tree-based map will start beating flat-map for inserts and deletes at some size n and continue pulling ahead since the k1∙O(log n) is a better order than k2∙O(n) even when k2 is much smaller than k1.

more speed

You can find videos of Stroustrup explaining why std::multimap is so slow(注記). See Why you shouldn't use set (and what you should use instead) by Matt Austern.

Use Boost.Container for flat_(multi)map which is a mature implementation based on Matt’s article, via Andrei Alexandrescu.

As a drop-in replacement, see what that does for your speed!


multimap.emplace_hint(range.first, std::make_pair(temp.hash, temp.move()));

That can (now) be written much more simply:

multimap.emplace_hint(range.first, { temp.hash, temp.move() } );

if (node->data.value == false)

Testing a bool against true/false is just strange. It is a bool; use it.

if (!node->data.value)

while (node != nullptr)

Don’t explicitly test against nullptr. Use the the truth value of the pointer’s value, which might (in the case of smart pointers) be an efficient operator bool in the class.

while (node)

addendum

(注記) A flat map wins for looking things up, which in my experience is the bulk of the run. The tree-based map will start beating flat-map for inserts and deletes at some size n and continue pulling ahead since the k1∙O(log n) is a better order than k2∙O(n) even when k2 is much smaller than k1.

added 383 characters in body
Source Link
JDługosz
  • 11.7k
  • 19
  • 40

more speed

You can find videos of Stroustrup explaining why std::multimap is so slow(注記). See Why you shouldn't use set (and what you should use instead) by Matt Austern.

Use Boost.Container for flat_(multi)map which is a mature implementation based on Matt’s article, via Andrei Alexandrescu.

As a drop-in replacement, see what that does for your speed!


multimap.emplace_hint(range.first, std::make_pair(temp.hash, temp.move()));

That can (now) be written much more simply:

multimap.emplace_hint(range.first, { temp.hash, temp.move() } );

if (node->data.value == false)

Testing a bool against true/false is just strange. It is a bool; use it.

if (!node->data.value)

while (node != nullptr)

Don’t explicitly test against nullptr. Use the the truth value of the pointer’s value, which might (in the case of smart pointers) be an efficient operator bool in the class.

while (node)

#addendum

(注記) A flat map wins for looking things up, which in my experience is the bulk of the run. The tree-based map will start beating flat-map for inserts and deletes at some size n and continue pulling ahead since the k1∙O(log n) is a better order than k2∙O(n) even when k2 is much smaller than k1.

more speed

You can find videos of Stroustrup explaining why std::multimap is so slow. See Why you shouldn't use set (and what you should use instead) by Matt Austern.

Use Boost.Container for flat_(multi)map which is a mature implementation based on Matt’s article, via Andrei Alexandrescu.

As a drop-in replacement, see what that does for your speed!


multimap.emplace_hint(range.first, std::make_pair(temp.hash, temp.move()));

That can (now) be written much more simply:

multimap.emplace_hint(range.first, { temp.hash, temp.move() } );

if (node->data.value == false)

Testing a bool against true/false is just strange. It is a bool; use it.

if (!node->data.value)

while (node != nullptr)

Don’t explicitly test against nullptr. Use the the truth value of the pointer’s value, which might (in the case of smart pointers) be an efficient operator bool in the class.

while (node)

more speed

You can find videos of Stroustrup explaining why std::multimap is so slow(注記). See Why you shouldn't use set (and what you should use instead) by Matt Austern.

Use Boost.Container for flat_(multi)map which is a mature implementation based on Matt’s article, via Andrei Alexandrescu.

As a drop-in replacement, see what that does for your speed!


multimap.emplace_hint(range.first, std::make_pair(temp.hash, temp.move()));

That can (now) be written much more simply:

multimap.emplace_hint(range.first, { temp.hash, temp.move() } );

if (node->data.value == false)

Testing a bool against true/false is just strange. It is a bool; use it.

if (!node->data.value)

while (node != nullptr)

Don’t explicitly test against nullptr. Use the the truth value of the pointer’s value, which might (in the case of smart pointers) be an efficient operator bool in the class.

while (node)

#addendum

(注記) A flat map wins for looking things up, which in my experience is the bulk of the run. The tree-based map will start beating flat-map for inserts and deletes at some size n and continue pulling ahead since the k1∙O(log n) is a better order than k2∙O(n) even when k2 is much smaller than k1.

Source Link
JDługosz
  • 11.7k
  • 19
  • 40

more speed

You can find videos of Stroustrup explaining why std::multimap is so slow. See Why you shouldn't use set (and what you should use instead) by Matt Austern.

Use Boost.Container for flat_(multi)map which is a mature implementation based on Matt’s article, via Andrei Alexandrescu.

As a drop-in replacement, see what that does for your speed!


multimap.emplace_hint(range.first, std::make_pair(temp.hash, temp.move()));

That can (now) be written much more simply:

multimap.emplace_hint(range.first, { temp.hash, temp.move() } );

if (node->data.value == false)

Testing a bool against true/false is just strange. It is a bool; use it.

if (!node->data.value)

while (node != nullptr)

Don’t explicitly test against nullptr. Use the the truth value of the pointer’s value, which might (in the case of smart pointers) be an efficient operator bool in the class.

while (node)
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /