Los Angeles, CA
Guidelines for C++ template-based micro-optimization
- Start with the lowest level, most frequently executed code first.
- Having chosen a fixed set of data types, implement the code in assembly.
- Reimplement the code in plain C, not using any abstract data types, so that it compiles into the same assembly instructions.
- Repeat steps 2 and 3 with a few different sets of data types.
- Take all of the C code from steps 2 and 4, and reimplement using C++ templates. Determine the template arguments.
- Identify all of the non-type-based validations needed by the template function.
- Identify all of the type-based validations needed by the template function.
- Package the template function into a class template method, and implement the non-type-based validations as its methods.
- Add the type-based validations to the class template.
- Identify any types, ones that a programmer-user might be tempted to instantiate the class template with, and test whether this would result in undesirable effects. (See note for step 10.)
- Implement additional type-based validations to guard against the scenarios identified in step 10.
Note for step 10.
- Compiler errors (failure to build) is a desirable effect, if the usage is indeed ill-formed.
- A successful build that results in an incorrect executable (one that produces incorrect result when executed) is the most severe undesirable effect.
- An unsuccessful build that results in hard-to-understand compiler error messages is a mildly undesirable effect.
- A source file that triggers compiler crashes (which may be possibly vendor-specific) is also a mildly undesirable effect.
Q&A for professional programmers interested in conceptual questions about software development
Q&A for professional and enthusiast programmers
Q&A for practitioners of the art and science of signal, image and video processing
Q&A for electronics and electrical engineering professionals, students, and enthusiasts
Q&A for user experience researchers and experts
Stack Exchange Network staging zone, where users come together to build new Q&A sites
Q&A for computer enthusiasts and power users
Q&A for members of the workforce navigating the professional setting
Q&A for active researchers, academics and students of physics
Q&A for professional and amateur chefs
Q&A for students, researchers and practitioners of computer science
Q&A for enthusiasts and power users of the Android operating system
Q&A for meta-discussion of the Stack Exchange family of Q&A websites
Q&A for peer programmer code reviews
Q&A for linguists, etymologists, and serious English language enthusiasts
Q&A for people studying math at any level and professionals in related fields
Q&A for people seeking specific software recommendations
Q&A for Ubuntu users and developers
Q&A for theoretical computer scientists and researchers in related fields
Q&A for passionate videogamers on all platforms
Q&A for power users of web applications
Q&A for professional, enthusiast and amateur photographers
Q&A for information security professionals
Q&A for cartographers, geographers and GIS professionals
Q&A for people interested in statistics, machine learning, data analysis, data mining, and data visualization
Q&A for users of Linux, FreeBSD and other Un*x-like operating systems
Q&A for project managers
Q&A for enthusiasts and power users of Windows Phone OS
Q&A for software quality control experts, automation engineers, and software testers
Q&A for professional robotic engineers, hobbyists, researchers and students
Q&A for people interested in improving and participating in the patent system
Q&A for scientists using computers to solve scientific problems
Q&A for those involved in the field of teaching mathematics
Q&A for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation
Q&A for people wanting to improve their personal productivity
Q&A for system and network administrators