Measure the test taker's knowledge about how to reduce the MRP data packet size.

Source: Internet
Author: User
Tags switch case

Reducing the MRP data packet size is saving memory space!

Since the MRP file is a compressed package of binary compilation, that is to say, the file will be loaded into the memory, occupying only less than KB of memory, so we should try to reduce the size of the file!

 

1. Use as few cross-file variables as possible. Introducing an external variable will increase mrp.


2. Avoid using macro-defined functions, especially macro functions with more code or a large number of times, which can be directly defined as functions.


3. Avoid using macro-defined functions. COLOR2PIXEL565 (0x00FFFFFF) can be directly written as 0 xFFFF;

4. Reduce the use of variables, including local variables
For example, no
Mr_screenRectSt rect;
Mr_colourSt color;

These variables can be replaced by the function that encapsulates and draws images!

5. Reduce function parameters
Solution for same 2

6. The constant defined by menu and # define have the same effect.

7. The color value can be replaced by UINT32, and RGB can be obtained by displacement operation!

8. # define-defined functions should be as short as possible. If there are small functions, it is best to define them as. # define

9. If the BOOL type is defined, use variable = TRUE to determine whether the variable is TRUE.

10. define a global variable as much as possible in files with few codes.

11. if the content of the switch case statement is correlated, you can replace it with for or if. It is best

12. Local variables are defined at the beginning of the function. If the local variables in the {} area inside the function are large or large, it is best to define them at the beginning of the function,


13. Local variables can be defined as static arrays. It is best!

14. Each function does only one thing! Do not have too many branches

 

There is no specific example for each piece. This requires programmers to understand it in actual programming!

CSDN blog address

Http://blog.csdn.net/kome2000/article/details/7278616

This article is only published in BKJIA and CSDN! Other addresses are not published by myself and are not approved by myself! Please note!

This article is from the "key code window" blog and will not be reprinted!

Related Article

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.