Sub4Sub network gives free YouTube subscribers
Get Free YouTube Subscribers, Views and Likes

The Dark Side of .reserve()

Follow
Logan Smith

.reserve(...) is a method you might've seen in the API of your favorite dynamic array (or hash table or whatnot), and it's an excellent tool for making simple, impactful performance optimizations while you are building up data structures. But just like all tools, it has sharp edges. In this video we'll dive into where .reserve() can make your performance singand where it can be devastating.

Special guest appearances from Unreal Engine, spline points, bigO notation, amortized constant complexity, exponential growth, C++ STL algorithms, good Rust design choices, and me forgetting to use the oldSize variable in the call to .resize() on the next line (but it's okay, I use it later on).

Starring:
std::vector::reserve https://en.cppreference.com/w/cpp/con...
Vec::reserve_exact https://doc.rustlang.org/std/vec/str...
TArray https://docs.unrealengine.com/5.2/en...
USplineComponent https://docs.unrealengine.com/5.2/en...

FBVector (great docs on selecting a good growth factor) https://github.com/facebook/folly/blo...

Contributing to Unreal https://docs.unrealengine.com/5.2/en...

I use the amazing Manim library for animating these videos, and I edit them with Blender and Audacity.
https://www.manim.community/
https://www.blender.org/
https://www.audacityteam.org/

posted by electryas