diff --git a/mbo/types/internal/decompose_count.h b/mbo/types/internal/decompose_count.h index 6e94e9b..01705fe 100644 --- a/mbo/types/internal/decompose_count.h +++ b/mbo/types/internal/decompose_count.h @@ -492,8 +492,7 @@ struct IsAggregateInitializableFromIndices; // types. This has the disadvantage that it effectively prevents `BinarySearch` from working in all // cases. Plus, it means that for every test we have to try a given number of base types which // multiplies the attempts O(N^2). Trying any type has a change to work with `BinarySearch` plus -// `ReverseSearch`: O(log(N)) + O(N). However, that may not work in which case we will apply -// `LinearSearch` plus `ReverseSearch` O(N) + O(N). So the chosen algorithm is O(N). +// `ReverseSearch`: O(log(N)) + O(N) --> O(N). template struct IsAggregateInitializableFromIndices> : std::bool_constant...>> {}; @@ -523,20 +522,13 @@ struct AggregateInitializerMidCount // The preference is to find somewhat high value as fast as possible. // Applying BinarySearch may however not work, as it may simply not try a workable number. -// In the failure case, the result is 0 and we try brut force to find the first workable number. +// In the failure case, the result is 0 and we will simply revert to worst case scenario for the next step. // From the number we found so far, we try the highest number, in reverse order (starting at End - 1). template struct AggregateInitializerCount : ReverseSearch< AggregateInitializeTest::template IsInitializable, - std::conditional_t< - AggregateInitializerMidCount::value != 0, - AggregateInitializerMidCount, - LinearSearch< - AggregateInitializeTest::template IsInitializable, - 0, - kFieldBlowupFactor * sizeof(T) + 1, - 0>>::value, + AggregateInitializerMidCount::value, kFieldBlowupFactor * sizeof(T) + 1, 0> {}; diff --git a/mbo/types/internal/decompose_count.h.mope b/mbo/types/internal/decompose_count.h.mope index a074673..4a317b4 100644 --- a/mbo/types/internal/decompose_count.h.mope +++ b/mbo/types/internal/decompose_count.h.mope @@ -155,8 +155,7 @@ struct IsAggregateInitializableFromIndices; // types. This has the disadvantage that it effectively prevents `BinarySearch` from working in all // cases. Plus, it means that for every test we have to try a given number of base types which // multiplies the attempts O(N^2). Trying any type has a change to work with `BinarySearch` plus -// `ReverseSearch`: O(log(N)) + O(N). However, that may not work in which case we will apply -// `LinearSearch` plus `ReverseSearch` O(N) + O(N). So the chosen algorithm is O(N). +// `ReverseSearch`: O(log(N)) + O(N) --> O(N). template struct IsAggregateInitializableFromIndices> : std::bool_constant...>> {}; @@ -186,20 +185,13 @@ struct AggregateInitializerMidCount // The preference is to find somewhat high value as fast as possible. // Applying BinarySearch may however not work, as it may simply not try a workable number. -// In the failure case, the result is 0 and we try brut force to find the first workable number. +// In the failure case, the result is 0 and we will simply revert to worst case scenario for the next step. // From the number we found so far, we try the highest number, in reverse order (starting at End - 1). template struct AggregateInitializerCount : ReverseSearch< AggregateInitializeTest::template IsInitializable, - std::conditional_t< - AggregateInitializerMidCount::value != 0, - AggregateInitializerMidCount, - LinearSearch< - AggregateInitializeTest::template IsInitializable, - 0, - kFieldBlowupFactor * sizeof(T) + 1, - 0>>::value, + AggregateInitializerMidCount::value, kFieldBlowupFactor * sizeof(T) + 1, 0> {};