Correct spelling.
[SquirrelJME.git] / assets / developer-notes / stephanie-gawroriski / 2016 / 03 / 18.mkd
bloba8fa625c80ace95cc23d74c4b6817d98d9b41717
1 # 2016/03/18
3 ## 16:02
5 Partially busy and distracting day today. For `String` compaction, I know of a
6 way where I can have a compact form of `String`s. Normally in ROM strings could
7 be be referenced by a byte array of sorts for standard ASCII characters. I
8 should note that some of these trade speed for memory and vice versa, however
9 for lower memory usage the slight speed cost could be a nice gain.
11 ## 16:02
13 There would be a mix of standard representation and dictionary types. The
14 dictionary can be ASCII (if all 8-bit values are used) or UTF-16 (if there are
15 these characters). The following types of string storage would be as follows:
17  * Standard 16-bit `char`.
18    * The normal Java representation, this will be the last resort posibility.
19  * Standard 8-bit.
20    * For values between 0 and 255 which are mapped directly to their unicode
21      values.
22  * Standard 7-bit with dictionary.
23    * Where strings that have mostly ASCII characters but need a few out of
24      0 to 255 range.
25  * Dictionary 8-bit.
26    * All characters are dictionary characters, so every entry references a
27      character in the index.
28    * This is used for strings where there are at most 256 distinct codepoints.
29  * Dictionary 4-bit.
30    * This is a string which takes up half of its space where there are 16
31      distinct codepoints which belong in a dictionary.
32    * This choice can always be followed if there are at most 16 characters in a
33      string.
34      * Problem with this however is that it might end up using more space if
35        a unique dictionary is required.
36  * Dictionary 2-bit.
37    * There are 4 characters to a byte.
38    * Also means that there is a limit of only 4 characters possible in a
39      string.
41 Also when strings are initialized and copied for example from `byte[]` or
42 `char[]`, I can scan the string to see if it is possible to construct any of
43 the above types. Although this would reduce speed, the input array and its
44 copy could be removed.
46 Dictionaries can also be shared between strings, so if one string has a subset
47 dictionary of another, they can share it.
49 ## 16:51
51 Some constructor issues, `UnsupportedEncodingException` is a checked exception
52 while some methods which use the default character set do not throw this
53 exception at all (since the default is always valid anyway). I would suppose to
54 avert this I could call a wrapper constructor of sorts which can magically
55 initialize a string internally.
57 ## 16:53
59 Also, I should probably clear out the `squirreljme` sub-package of stuff that
60 does not need to be there. I am going to declare that said package should only
61 contain stuff needed by the class library similar to `com.sun` and such.