Internal VC ++ simple to use and switch case 6.0 optimization scheme

Create a file of VC ++ 6.0

  • Step one: Open the Microsoft Visual C ++ 6.0
  • Step two: Click the top left corner of the File, New
  • Step 3: Click C ++ Source File under the File column, then enter the corresponding file name and file storage directory to create a new .cfile

Using VC ++ 6.0 shortcuts

  • F1: bring up the MSDN (query function help file)
  • F5: compiled commissioning
  • F7: Compile + Link
  • F9: The current row is added / canceled breakpoint
  • F10: Step over (single-step)
  • F11: step into (Step Into, viewing functions implemented)
  • CTRL + F5: direct operation
  • CTRL + F7: only the compiler does not link
  • Shift + F11: Step out (jump)
  • CTRL + F10: Single-step jump cursor to mouse clicks
  • ALT + 8: Jump to disassembly window
  • IDE (Integrated Development Environment): Integrated Development Environment
Example:

VC ++ 6.0 menu bar adjustment:

Window VC ++ 6.0 debugger, you need to use: Memory window, watch window, the window stack, register windows.

In programming, the mouse cursor can be placed on the library functions want to know, press the F1 key to MSDN Help documentation pop-up.

VC ++ 6.0 using Alt + 8 to open the disassembly window of the current line, but also can right-click the window, click on the "Code Bytes" view corresponding machine code.

Use under Windows XP VC ++ 6.0 to view the distribution of memory, can be found before 4GB memory space of 2GB front 64KB, after 64KB memory space is part of the system reserved area, before 64KB used to make an invalid pointer, invalid assignment examination, 64KB with do interactive kernel.

API PK library functions

Look environment: If you do not build cache, fread on the efficiency of library functions than a little slower.
malloc (C library functions) -> HeapAlloc (API function)
different platform C compiler will interface to the platform to do some work package.

if else

Complex condition judgment can be done, can set the priority condition (the amount of data execution conditions is placed in front), the interval is determined to do, flexible.
Disadvantages: ladder, and if the number of comparison times more, then it is no good effect switch case.

switch case

The value must be an integer-based case: Class Integer Integer or ASCII ( 'A'), long (5L) type may be used.
The switch statement is an optimized version of the branch structure, in the compilation of this era structure a lot of people use, then C / C ++ standards committee feel that this structure is very practical, then it will be integrated into grammar framework of the C language, the following will be named for the switch structure. Both times in place, for the first time calculated value of the switch expression, jump access memory based on the value of the corresponding address table.

One switch case inner optimization (continuous or relatively continuous scheme)

When the positive case values ​​arranged in order of the distribution of the memory is as follows

Found in the memory address table, the corresponding lower case values stored in the code address is a continuous
basic structure thought: The value of the switch in the expression, to find the index value corresponding to the case the memory address table memory.

When the reverse order disrupted case values, distribution of the memory is as follows

Even if the value of the order of the case were changed, but the memory address table can be found by the case, case the value is still ordered.

The value transfer large case, out of sequence, an interval value is not case:


By disassembly window can be found in case the value of 20 start from the top 20 is null, as the first 20 elements in the array is the same as a null value, store null values ​​does not make sense, so the internal system of coordinate translation, even if the value of case after disrupting sequence, can be found by the memory address table case, the value is still carried out by sequentially arrayed

The case of a discontinuous value is set, for the intermediate hop value, a value from 20 to case 28 removed 23,25,27


And an address can be found by disassembly window case the address table memory which case the value is still continuously arranged, missing values ​​intermediate case 23, case 25, case27 have been filled with the default address of the next sentence.

The spacing between the case and the value of the five values ​​(more than 5)


Case can be seen that the distribution of values ​​in memory no longer a continuous

get conclusion

  • Each case branch of efficiency equal access switch
  • Regardless of position adjustment case will not affect their access efficiency

four sets of switch case structure optimization scheme is more continuous or continuous embodiment illustrated above: the case must be greater than the number of three, so that it can only optimization action, the case requires a continuous value, if not continuous, the intermediate value can not be lacking more than 5, if more than 5 or equal to 5, then its memory is not stored contiguously.
decimal value of the case not because it is stored in memory array structure similar to the storage structure, the need for look-up table in memory based on the value of the switch expression, based on this, in case the value must be an integer type.

Guess you like

Origin www.cnblogs.com/ileemi/p/12625782.html