C + + Programming optimization experience (continuous update)

Source: Internet
Author: User

1. The alignment principle. For example, 64-bit bus, each address read 8B. Pay attention to the variable address when programming, and consume the least number of addresses of the bus. Heap memory request, the system is strictly aligned according to the principle of alignment, so use time also try not to cross the addressing boundary.

2. When needed, the code can be copied for efficiency, although the code volume is increased, but it is worthwhile. Especially for loops, if the number of times is less, it is no harm to disassemble.

3. Bit operation,-1 right shift, left 1, it is still -1;-1 left shift, right 0, it is no longer 1.

4. Each application of the heap memory, preferably initialized, the inside is garbage data, and not empty.

5. In project development, often an engine exposes a pure virtual class, and its interface is the * * pointer variable of this class.

C + + Programming optimization experience (continuous update)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.