Changes between Version 10 and Version 11 of ResumedC
- Timestamp:
- Apr 29, 2009, 3:22:26 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ResumedC
v10 v11 208 208 Image 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 209 209 210 Normal structure :210 Normal structure, total: '''48''' bits 211 211 || ||0 ||1 ||2 ||3 ||4 ||5 ||6 ||7 ||8 ||9 ||10 ||11 ||12 ||13 ||14 ||15 || 212 212 ||seen ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. || … … 214 214 ||number ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. || 215 215 216 Packaged structure :216 Packaged structure, total '''16''' bits 217 217 ||0 ||1 ||2 ||3 ||4 ||5 ||6 ||7 ||8 ||9 ||10 ||11 ||12 ||13 ||14 ||15 || 218 218 ||[seen] ||[list] ||[number ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||number] || … … 321 321 #!C 322 322 struct mailing { 323 char name[60]; 324 char address[120]; 323 325 ... 324 326 } list[MAX_ENTRIES]; 325 327 326 struct mailing *list_p[MAX_ENTRIES]; 327 328 for (current... 329 list_p[current] = &list[current]; 328 struct mailing *list_ptrs[MAX_ENTRIES]; 329 int current; 330 331 for (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 */ 330 334 }}} 331 335