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