Prompt
Apply small performance improvements that accumulate to significant gains. Focus on efficient memory usage, API choices, and avoiding unnecessary operations.
Key practices:
- Use references instead of copies when possible:
auto& dynamic = std::get<folly::dynamic>(value_)instead offolly::dynamic dynamic = std::get<folly::dynamic>(value_) - Prefer faster API variants: use
getObject()instead ofasObject()when you’ve already validated withisObject()- it’s faster because it uses an assert - Use move semantics and emplace for containers:
result.emplace(propertyNameString, std::move(property))instead ofresult[propertyNameString] = propertyfor better performance with no unnecessary copies - Avoid expensive memory operations: use stack allocation
CGFloat locations[colorStops.size()]instead ofmalloc(sizeof(CGFloat) * colorStops.size())
These micro-optimizations are especially important in performance-critical code paths where small improvements compound across many operations.