Changes between Version 10 and Version 11 of ResumedC


Ignore:
Timestamp:
Apr 29, 2009, 3:22:26 AM (15 years ago)
Author:
Thanatermesis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ResumedC

    v10 v11  
    208208Image an application that stupidly takes a lot of storage but very few 'cpu' usage and you will need to optimize it for data, imagine that it has 3 variables, ''seen'' is used to know if the element is seen, and ''list'' is used to know if the element is on the list, and ''number'' is the number of the element (the ''data''). Between ''number'' needs to be a full ''int'' that requires 16 bits (or a little less than it), you can set ''seen'' and ''list'' to use only 1 bit each one, and ''number'' to use 14 instead of 16, on that way, you will have the full size of the structure 3 times smaller than originally
    209209
    210 Normal structure:
     210Normal structure, total: '''48''' bits
    211211|| ||0 ||1 ||2 ||3 ||4 ||5 ||6 ||7 ||8 ||9 ||10 ||11 ||12 ||13 ||14 ||15 ||
    212212||seen ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||
     
    214214||number ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||
    215215
    216 Packaged structure:
     216Packaged structure, total '''16''' bits
    217217||0 ||1 ||2 ||3 ||4 ||5 ||6 ||7 ||8 ||9 ||10 ||11 ||12 ||13 ||14 ||15 ||
    218218||[seen] ||[list] ||[number ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||number] ||
     
    321321#!C
    322322struct mailing {
     323   char name[60];
     324   char address[120];
    323325   ...
    324326} list[MAX_ENTRIES];
    325327
    326 struct mailing *list_p[MAX_ENTRIES];
    327 
    328 for (current...
    329    list_p[current] = &list[current];
     328struct mailing *list_ptrs[MAX_ENTRIES];
     329int current;
     330
     331for (current = 0; current = number_of_entries; ++current)
     332   list_ptrs[current] = &list[current];
     333/* Now we have in every list_prts[element], a pointer to the equivalent list[element] array of structures */
    330334}}}
    331335