Efficient Kotlin
summary
Shows concrete costs and fixes: single object allocation and header sizes (object header ~8–12 bytes), boxed Integer overhead (boxed Integer ~16 bytes + reference, 5–6× primitive), and measurable wins from avoiding allocations. Demonstrates caching patterns (map cache, soft references + property delegate), regex and static-initialization lifting with lazy, and when to prefer Sequence for >10k elements (benchmarks show ~30–50% faster on big collections). Recommends inline functions, inline classes as zero-cost wrappers, and nulling array slots to avoid leaks.
AI-written summary · about
chapters (21)
- 0:00Start
- 5:13Object Declaration
- 5:40Object Declarations
- 6:38Factory Functions with Cash
- 8:59Weak Reference
- 10:28Object Lifting
- 13:09Using Primitives
- 14:55Boundary Functions
- 16:22Inline Modifier
- 19:49Crossing Line and Non in Line
- 23:43Inline Classes
- 32:42Efficient Collection Processing
- 33:33Difference between Iterable and Sequence
- 38:51Small Collections
- 39:51Sequence Debugger
- 40:14Limit the Number of Operations
- 41:06Easier Alternatives for Common Collection Processing Patterns
- 43:14Multiple Collections
- 45:42Questions
- 46:10Benchmarks
- 53:08Fibonacci Numbers
