- Minor performance adjustments
This commit is contained in:
@@ -41,7 +41,6 @@
|
||||
// -> Cache Locality
|
||||
// -> log(n) runtime
|
||||
// -> No auxiliary structures or constant runtimes
|
||||
// -> Only needs an extra byte for color
|
||||
//
|
||||
// I tried just about every heap under the sun
|
||||
// -> strict fibonacci heap, got blown out of the water by std::priority_queue
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
// https://www.geeksforgeeks.org/dsa/insertion-in-red-black-tree/
|
||||
|
||||
// Uncertain how I managed to do this, but this data structure has
|
||||
// A 50%-100% performance increase over std::set when running Dijkstra's
|
||||
// A 33%-100% performance increase over std::set when running Dijkstra's
|
||||
//
|
||||
// Guesses:
|
||||
// -> I likely make some assumptions that std::set doesn't
|
||||
@@ -53,6 +53,11 @@
|
||||
// Some of the implementations I have seen have multiple levels
|
||||
// of if statements based on directionality which causes branching.
|
||||
// I use const-expressions that reduce down to cmov instructions
|
||||
//
|
||||
//
|
||||
// I ran some more performance tests, and it does not hold up well at the larger end of things.
|
||||
// I think something with the balancing on insertion is a tad messed up.
|
||||
//
|
||||
|
||||
namespace fennec
|
||||
{
|
||||
@@ -377,11 +382,17 @@ protected:
|
||||
size_t d = direction(n);
|
||||
size_t r = direction(p);
|
||||
|
||||
// Case 4
|
||||
if (g == npos) {
|
||||
_color(p) = black;
|
||||
return;
|
||||
}
|
||||
|
||||
// Split 4 node
|
||||
if (color(u) == red) {
|
||||
_recolor(g);
|
||||
n = p;
|
||||
p = g;
|
||||
n = g;
|
||||
p = parent(n);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -392,7 +403,7 @@ protected:
|
||||
|
||||
// LL & RR case
|
||||
rotate(g, not r);
|
||||
n = parent(n);
|
||||
n = grandparent(n);
|
||||
p = parent(n);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user