Changes between Version 9 and Version 10 of ResumedC


Ignore:
Timestamp:
Apr 29, 2009, 3:14:10 AM (16 years ago)
Author:
Thanatermesis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ResumedC

    v9 v10  
    206206
    207207==== Packaged structures ====
    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, you can set the value of the bits to use for the structure elements, like:
     208Image 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
     210Normal structure:
     211|| ||0 ||1 ||2 ||3 ||4 ||5 ||6 ||7 ||8 ||9 ||10 ||11 ||12 ||13 ||14 ||15 ||
     212||seen ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||
     213||list ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||
     214||number ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||
     215
     216Packaged structure:
     217||0 ||1 ||2 ||3 ||4 ||5 ||6 ||7 ||8 ||9 ||10 ||11 ||12 ||13 ||14 ||15 ||
     218||[seen] ||[list] ||[number ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||. ||number] ||
    209219{{{
    210220#!C
    211221struct item {
    212222   unsigned int seen:1;
    213    ...
     223   unsigned int list:1;
     224   unsigned int number:14;
    214225   }
    215 /* Now the variable 'seen' (seen or not seen) only takes one BIT */
    216226}}}
    217227 The bad point of this usage is that it the access to this data is pretty more slow than in normal mode, so do this only when is really needed to save storage space.