C++ Footprint and Performance Optimization Copyright About the Authors Acknowledgments Tell Us What You Think! Introduction: Why Optimize? Aim of This Book Who This Book Is For The Structure of This Book Part I: Everything But the Code Chapter Optimizing: What Is It All About? Performance Footprint Summary Chapter Creating a New System System Requirements System Design Issues The Development Process Data Processing Methods Summary Chapter Modifying an Existing System Identifying What to Modify Beginning Your Optimization Analyzing Target Areas Performing the Optimizations Summary Part II: Getting Our Hands Dirty Chapter Tools and Languages Tools You Cannot Do Without Optimizing with Help from the Compiler The Language for the Job Summary Chapter Measuring Time and Complexity The Marriage of Theory and Practice System Influences Summary Chapter The Standard C/C++ Variables Variable Base Types Grouping Base Types Summary Chapter Basic Programming Statements Selectors Loops Summary Chapter Functions Invoking Functions Passing Data to Functions Early Returns Functions as Class Methods Summary Chapter Efficient Memory Management Memory Fragmentation Memory Management Resizable Data Structures Summary Chapter 10 Blocks of Data Comparing Blocks of Data The Theory of Sorting Data Sorting Techniques Summary Chapter 11 Storage Structures Arrays Linked Lists Hash Tables Binary Trees Red/Black Trees Summary Chapter 12 Optimizing IO Efficient Screen Output Efficient Binary File IO Efficient Text File IO Summary Note that the way in which data is placed in tmp and shifted upwards in the direction of the most significant byte, makes it ideal for big-endian implementations If, however, you would like to receive the bytes of the device in a little-endian order, some changes need to be made as shown in Listing 15.14 Listing 15.14 Efficient Hardware Address Access (Little-Endian) unsigned char buffer[1024]; for (int i = 0; i < buflen; i+= 4) { register long tmp; tmp = (*HARDWAREMAPPEDREGI tmp |= (*HARDWAREMAPPEDREGI tmp |= (*HARDWAREMAPPEDREGI tmp |= (*HARDWAREMAPPEDREGI buffer[i] = tmp } CONTENTS ... The Marriage of Theory and Practice System Influences Summary Chapter The Standard C/ C++ Variables Variable Base Types Grouping Base Types Summary Chapter Basic Programming Statements Selectors... Structures Summary Chapter 10 Blocks of Data Comparing Blocks of Data The Theory of Sorting Data Sorting Techniques Summary Chapter 11 Storage Structures Arrays Linked Lists Hash Tables Binary... Summary Chapter Functions Invoking Functions Passing Data to Functions Early Returns Functions as Class Methods Summary Chapter Efficient Memory Management Memory Fragmentation Memory Management Resizable