Strings: case sensistive custom implementations
(Created page with "Author: Serge Billault The following tips are not meant to be absolutes but rather guidelines for Unity users that want to produce well performing code. == Scripting == So...") |
m |
||
Line 10: | Line 10: | ||
In the 80s/90s, when we were cracking video games we would often notice in the BSS section of the executables some recuring data structures that were resembling | In the 80s/90s, when we were cracking video games we would often notice in the BSS section of the executables some recuring data structures that were resembling | ||
− | <br>a 256 chraracters table hosting a | + | <br>a 256 chraracters table hosting a variation of the alphabet. These are conversion tables. Conversion tables are used whenever a direct match exist between |
<br>a data to convert and the converted data using direct indexing. That's how we were so fast on systems running at 8 Mhz. | <br>a data to convert and the converted data using direct indexing. That's how we were so fast on systems running at 8 Mhz. | ||
Revision as of 04:10, 7 October 2020
Author: Serge Billault
The following tips are not meant to be absolutes but rather guidelines for Unity users that want to produce well performing code.
Scripting
Sometimes the need to implement custom case conversions for custom string classes arise. It is not for us to judge if the intiative is well founded but we can attract
the attention on some common pitfalls encounterd by those who attempt it for the first time.
In the 80s/90s, when we were cracking video games we would often notice in the BSS section of the executables some recuring data structures that were resembling
a 256 chraracters table hosting a variation of the alphabet. These are conversion tables. Conversion tables are used whenever a direct match exist between
a data to convert and the converted data using direct indexing. That's how we were so fast on systems running at 8 Mhz.
In the particular case of string case convertions, the same principle can be applied to printable letters using a conversion table. Such tables also exist for
conversion from integral values to hexadecimal literals.
Exemple
Table commonly used for case convertions and ignore-case comparisons.
1) In the case of ignore-case comparisons we simply compare TO_CASE[ left_char ] to TO_CASE[ right_char ] with TO_CASE being either TO_UPPER ot TO_LOWER. 2) In the case of string case conversion, car become either TO_UPPER[ char ] ot TO_LOWER[ char ].
image being uploaded, patience