make case tables immutable

- Avoids redundant object copies and semantic
  analysis for every usage.

- Multilib archives or gc-sections will take care
  of the binary size issue.
This commit is contained in:
Martin Nowak 2013-10-13 20:50:40 +02:00
parent 713c72c0dc
commit 45c873faf3
2 changed files with 4 additions and 4 deletions

View file

@ -58,7 +58,7 @@ struct TrieEntry(T...)
size_t[] data; size_t[] data;
} }
enum simpleCaseTable = [ immutable simpleCaseTable = [
SimpleCaseEntry(0x2c00, 0, 0x82), SimpleCaseEntry(0x2c00, 0, 0x82),
SimpleCaseEntry(0x2c30, 1, 0x42), SimpleCaseEntry(0x2c30, 1, 0x42),
SimpleCaseEntry(0x24c3, 0, 0x82), SimpleCaseEntry(0x24c3, 0, 0x82),
@ -2216,7 +2216,7 @@ enum simpleCaseTable = [
SimpleCaseEntry(0x24c0, 0, 0x82), SimpleCaseEntry(0x24c0, 0, 0x82),
SimpleCaseEntry(0x24da, 1, 0x42) SimpleCaseEntry(0x24da, 1, 0x42)
]; ];
enum fullCaseTable = [ immutable fullCaseTable = [
FullCaseEntry("Ⰰ", 0, 2, 1), FullCaseEntry("Ⰰ", 0, 2, 1),
FullCaseEntry("ⰰ", 1, 2, 1), FullCaseEntry("ⰰ", 1, 2, 1),
FullCaseEntry("Ⓝ", 0, 2, 1), FullCaseEntry("Ⓝ", 0, 2, 1),

View file

@ -5552,7 +5552,7 @@ unittest
int sicmp(C1, C2)(const(C1)[] str1, const(C2)[] str2) int sicmp(C1, C2)(const(C1)[] str1, const(C2)[] str2)
{ {
static immutable simpleCaseTrie = asTrie(simpleCaseTrieEntries); static immutable simpleCaseTrie = asTrie(simpleCaseTrieEntries);
static immutable sTable = simpleCaseTable; alias sTable = simpleCaseTable;
size_t ridx=0; size_t ridx=0;
foreach(dchar lhs; str1) foreach(dchar lhs; str1)
{ {
@ -5593,7 +5593,7 @@ int sicmp(C1, C2)(const(C1)[] str1, const(C2)[] str2)
private int fullCasedCmp(Range)(dchar lhs, dchar rhs, ref Range rtail) private int fullCasedCmp(Range)(dchar lhs, dchar rhs, ref Range rtail)
{ {
static immutable fullCaseTrie = asTrie(fullCaseTrieEntries); static immutable fullCaseTrie = asTrie(fullCaseTrieEntries);
static immutable fTable = fullCaseTable; alias fTable = fullCaseTable;
size_t idx = fullCaseTrie[lhs]; size_t idx = fullCaseTrie[lhs];
// fullCaseTrie is packed index table // fullCaseTrie is packed index table
if(idx == EMPTY_CASE_TRIE) if(idx == EMPTY_CASE_TRIE)