Book description
NoneTable of contents
- Preface
- 1. An Overview of Optimization
-
2. Computer Behavior Affecting Optimization
- Lies C++ Believes About Computers
-
The Truth About Computers
- Memory Is Slow
- Memory Is Not Accessed in Bytes
- Some Memory Accesses Are Slower than Others
- Memory Words Have a Big End and a Little End
- Memory Has Finite Capacity
- Instruction Execution Is Slow
- Making Decisions Is Hard for Computers
- There Are Multiple Streams of Program Execution
- Calling into the Operating System Is Expensive
- C++ Tells Lies Too
- Summary
- 3. Measure Performance
-
4. Optimize String Use: A Case Study
- Why Strings Are a Problem
-
First Attempt at Optimizing Strings
- Use Mutating String Operations to Eliminate Temporaries
- Reduce Reallocation by Reserving Storage
- Eliminate Copying of String Arguments
- Eliminate Pointer Dereference Using Iterators
- Eliminate Copying of Returned String Values
- Use Character Arrays Instead of Strings
- Summary of First Optimization Attempt
- Second Attempt at Optimizing Strings
- Eliminate String Conversion
- Summary
- 5. Optimize Algorithms
- 6. Optimize Dynamically Allocated Variables
-
7. Optimize Hot Statements
-
Remove Code from Loops
- Cache the Loop End Value
- Use More Efficient Loop Statements
- Count Down Instead of Up
- Remove Invariant Code from Loops
- Remove Unneeded Function Calls from Loops
- Remove Hidden Function Calls from Loops
- Remove Expensive, Slow-Changing Calls from Loops
- Push Loops Down into Functions to Reduce Call Overhead
- Do Some Actions Less Frequently
- What About Everything Else?
-
Remove Code from Functions
- Cost of Function Calls
- Declare Brief Functions Inline
- Define Functions Before First Use
- Eliminate Unused Polymorphism
- Discard Unused Interfaces
- Select Implementation at Compile Time with Templates
- Eliminate Uses of the PIMPL Idiom
- Eliminate Calls into DLLs
- Use Static Member Functions Instead of Member Functions
- Move Virtual Destructor to Base Class
- Optimize Expressions
- Optimize Control Flow Idioms
- Summary
-
Remove Code from Loops
-
8. Use Better Libraries
- Optimize Standard Library Use
- Optimize Existing Libraries
-
Design Optimized Libraries
- Code in Haste, Repent at Leisure
- Parsimony Is a Virtue in Library Design
- Make Memory Allocation Decisions Outside the Library
- When in Doubt, Code Libraries for Speed
- Functions Are Easier to Optimize than Frameworks
- Flatten Inheritance Hierarchies
- Flatten Calling Chains
- Flatten Layered Designs
- Avoid Dynamic Lookup
- Beware of âGod Functionsâ
- Summary
- 9. Optimize Searching and Sorting
- 10. Optimize Data Structures
- 11. Optimize I/O
- 12. Optimize Concurrency
- 13. Optimize Memory Management
- Index
Product information
- Title: Optimized C++
- Author(s):
- Release date:
- Publisher(s):
- ISBN: None
You might also like
book
Learning Modern C++ for Finance
A lot of financial modeling has gravitated toward Python, R, and VBA, but many developers hit …
video
Learning C++ Best Practices
In this Learning C++ Best Practices training course, expert author Jason Turner will teach you how …
book
Fundamentals of Data Engineering
Data engineering has grown rapidly in the past decade, leaving many software engineers, data scientists, and …
book
C++20 for Lazy Programmers: Quick, Easy, and Fun C++ for Beginners
Ready to learn programming with less effort and more fun? Then do it the lazy way! …