MCPcopy Create free account
hub / github.com/FastLED/FastLED / reserve

Function reserve

src/fl/stl/unordered_map.h:788–801  ·  view source on GitHub ↗

reserve(size_type n) - reserve capacity for at least n elements

Source from the content-addressed store, hash-verified

786
787 // reserve(size_type n) - reserve capacity for at least n elements
788 void reserve(fl::size n) {
789 // Calculate required buckets to hold n elements without exceeding load factor
790 float max_lf = max_load_factor();
791 if (max_lf <= 0.0f) {
792 max_lf = 0.7f; // Default if somehow zero
793 }
794 // Required buckets = ceil(n / max_load_factor)
795 fl::size required_buckets = static_cast<fl::size>(
796 static_cast<float>(n) / max_lf + 0.999999f // Add almost 1 to simulate ceil
797 );
798 if (required_buckets > _buckets.size()) {
799 rehash(required_buckets);
800 }
801 }
802
803 private:
804 static fl::size npos() {

Callers

nothing calls this directly

Calls 3

max_load_factorFunction · 0.85
rehashFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected