Chapter 5

Unsafe Optimizations

Learn when and how to use unsafe for zero-copy string/byte conversions

✓ Understand unsafe.Pointer ✓ Zero-copy conversions ✓ Know the risks
1
Zero-Copy String Conversion
Use unsafe.Pointer for zero-allocation string/byte slice conversions - as used in American Express's simplemli
orijtech.github.io/talks/2021/12/02/amex/go_machine_guides.htm#28 +30 XP advanced
2
Map String Lookup Optimization
Use map[string(byteslice)] pattern for zero-allocation map lookups
orijtech.github.io/talks/2021/12/02/amex/go_machine_guides.htm#24 +20 XP intermediate
3
Efficient Map Clearing
The fast way to clear a map - recognized by the Go compiler for optimization
orijtech.github.io/talks/2021/12/02/amex/go_machine_guides.htm#25 +20 XP intermediate