fixed bad typing (int* instead of T*) and faster branchless codes
This commit is contained in:
parent
d2b4e5bf94
commit
04964cd2a0
@ -35,7 +35,7 @@ class TurboList {
|
|||||||
old = nex;
|
old = nex;
|
||||||
mid = end;
|
mid = end;
|
||||||
capacity *= 2;
|
capacity *= 2;
|
||||||
nex = (int *) MALLOC(this->capacity * sizeof(T));
|
nex = (T *) MALLOC(this->capacity * sizeof(T));
|
||||||
|
|
||||||
// Will go into the INSERT code path here
|
// Will go into the INSERT code path here
|
||||||
return insert(elem);
|
return insert(elem);
|
||||||
@ -48,7 +48,7 @@ public:
|
|||||||
end(initial_size),
|
end(initial_size),
|
||||||
capacity(initial_cap) {
|
capacity(initial_cap) {
|
||||||
|
|
||||||
nex = (int *) MALLOC(this->capacity * sizeof(T));
|
nex = (T *) MALLOC(this->capacity * sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ~TurboList() noexcept {
|
inline ~TurboList() noexcept {
|
||||||
@ -57,7 +57,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline T& operator[](uint32_t i) noexcept {
|
inline T& operator[](uint32_t i) noexcept {
|
||||||
return (i < mid) ? old[i] : nex[i];
|
// This seem to be more often compiled to cmov
|
||||||
|
// branchless conditional codes this way..
|
||||||
|
T *base = (i < mid) ? old : nex;
|
||||||
|
return base[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is much faster than operator[] if you do small amounts of work per access */
|
/** This is much faster than operator[] if you do small amounts of work per access */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user