Author: atsushi
Date: 2005-07-05 08:54:04 -0400 (Tue, 05 Jul 2005)
New Revision: 46943
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
trunk/mcs/class/corlib/Mono.Globalization.Unicode/CodePointIndexer.cs
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.cs
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTableUtil.cs
trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
Log:
2005-07-05 Atsushi Enomoto <[EMAIL PROTECTED]>
* MSCompatUnicodeTableUtil.cs,
MSCompatUnicodeTable.cs,
CodePointIndexer.cs,
create-mscompat-collation-table.cs : made some members internal and
accessible from other classes. Many indexes could be 0 by default.
* SimpleCollator.cs : optimizations. avoid method call.
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog 2005-07-05
12:49:40 UTC (rev 46942)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/ChangeLog 2005-07-05
12:54:04 UTC (rev 46943)
@@ -1,5 +1,14 @@
2005-07-05 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * MSCompatUnicodeTableUtil.cs,
+ MSCompatUnicodeTable.cs,
+ CodePointIndexer.cs,
+ create-mscompat-collation-table.cs : made some members internal and
+ accessible from other classes. Many indexes could be 0 by default.
+ * SimpleCollator.cs : optimizations. avoid method call.
+
+2005-07-05 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* Collation-notes.txt : more updates.
* SimpleCollator.cs : Added quick check for Ordinal comparison.
Fixed special weight comparison. It cannot be customizable in the
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/CodePointIndexer.cs
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/CodePointIndexer.cs
2005-07-05 12:49:40 UTC (rev 46942)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/CodePointIndexer.cs
2005-07-05 12:54:04 UTC (rev 46943)
@@ -71,9 +71,12 @@
public int ToIndex (int cp)
{
- for (int t = 0; t < ranges.Length; t++)
- if (ranges [t].Start <= cp && cp < ranges
[t].End)
+ for (int t = 0; t < ranges.Length; t++) {
+ if (cp < ranges [t].Start)
+ return defaultIndex;
+ else if (cp < ranges [t].End)
return cp - ranges [t].Start + ranges
[t].IndexStart;
+ }
return defaultIndex;
// throw new SystemException (String.Format ("Should not
happen: no map definition for cp {0:x}({1})", cp, (char) cp));
}
@@ -81,12 +84,19 @@
public int ToCodePoint (int i)
{
for (int t = 0; t < ranges.Length; t++) {
+/*
if (t > 0 && i < ranges [t - 1].IndexEnd)
- return -1; // unexpected out of range
+ return defaultCP; // unexpected out of
range
if (ranges [t].IndexStart <= i &&
i < ranges [t].IndexEnd)
return i - ranges [t].IndexStart
+ ranges [t].Start;
+*/
+ if (i < ranges [t].IndexStart)
+ return defaultCP;
+ if (i < ranges [t].IndexEnd)
+ return i - ranges [t].IndexStart
+ + ranges [t].Start;
}
return defaultCP;
// throw new SystemException (String.Format ("Should not
happen: no map definition for index {0:x}({1})", i, i));
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.cs
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.cs
2005-07-05 12:49:40 UTC (rev 46942)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.cs
2005-07-05 12:54:04 UTC (rev 46943)
@@ -59,26 +59,22 @@
public static byte Categories (int cp)
{
- int idx = UUtil.Category.ToIndex (cp);
- return idx < 0 ? byte.MinValue : categories [idx];
+ return categories [UUtil.Category.ToIndex (cp)];
}
public static byte Level1 (int cp)
{
- int idx = UUtil.Level1.ToIndex (cp);
- return idx < 0 ? byte.MinValue : level1 [idx];
+ return level1 [UUtil.Level1.ToIndex (cp)];
}
public static byte Level2 (int cp)
{
- int idx = UUtil.Level2.ToIndex (cp);
- return idx < 0 ? byte.MinValue : level2 [idx];
+ return level2 [UUtil.Level2.ToIndex (cp)];
}
public static byte Level3 (int cp)
{
- int idx = UUtil.Level3.ToIndex (cp);
- return idx < 0 ? byte.MinValue : level3 [idx];
+ return level3 [UUtil.Level3.ToIndex (cp)];
}
public static bool IsIgnorable (int cp)
@@ -214,12 +210,12 @@
static readonly char [] tailorings;
static readonly TailoringInfo [] tailoringInfos;
- static readonly byte [] ignorableFlags;
- static readonly byte [] categories;
- static readonly byte [] level1;
- static readonly byte [] level2;
- static readonly byte [] level3;
- static readonly ushort [] widthCompat;
+ internal static readonly byte [] ignorableFlags;
+ internal static readonly byte [] categories;
+ internal static readonly byte [] level1;
+ internal static readonly byte [] level2;
+ internal static readonly byte [] level3;
+ internal static readonly ushort [] widthCompat;
static ushort [] cjkCHS;
static ushort [] cjkCHT;
static ushort [] cjkJA;
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTableUtil.cs
===================================================================
---
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTableUtil.cs
2005-07-05 12:49:40 UTC (rev 46942)
+++
trunk/mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTableUtil.cs
2005-07-05 12:54:04 UTC (rev 46943)
@@ -63,11 +63,11 @@
int [] cjkEnds = new int [] {0xA000};
Ignorable = new CodePointIndexer (ignoreStarts,
ignoreEnds, -1, -1);
- Category = new CodePointIndexer (catStarts, catEnds,
-1, -1);
- Level1 = new CodePointIndexer (lv1Starts, lv1Ends, -1,
-1);
- Level2 = new CodePointIndexer (lv2Starts, lv2Ends, -1,
-1);
- Level3 = new CodePointIndexer (lv3Starts, lv3Ends, -1,
-1);
- WidthCompat = new CodePointIndexer (widthStarts,
widthEnds, -1, -1);
+ Category = new CodePointIndexer (catStarts, catEnds, 0,
0);
+ Level1 = new CodePointIndexer (lv1Starts, lv1Ends, 0,
0);
+ Level2 = new CodePointIndexer (lv2Starts, lv2Ends, 0,
0);
+ Level3 = new CodePointIndexer (lv3Starts, lv3Ends, 0,
0);
+ WidthCompat = new CodePointIndexer (widthStarts,
widthEnds, 0, 0);
CjkCHS = new CodePointIndexer (chsStarts, chsEnds, -1,
-1);
Cjk = new CodePointIndexer (cjkStarts, cjkEnds, -1, -1);
}
Modified: trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
===================================================================
--- trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
2005-07-05 12:49:40 UTC (rev 46942)
+++ trunk/mcs/class/corlib/Mono.Globalization.Unicode/SimpleCollator.cs
2005-07-05 12:54:04 UTC (rev 46943)
@@ -62,6 +62,30 @@
static SimpleCollator invariant =
new SimpleCollator (CultureInfo.InvariantCulture);
+ internal static readonly byte [] ignorableFlags =
+ Uni.ignorableFlags;
+ internal static readonly byte [] categories =
+ Uni.categories;
+ internal static readonly byte [] level1 =
+ Uni.level1;
+ internal static readonly byte [] level2 =
+ Uni.level2;
+ internal static readonly byte [] level3 =
+ Uni.level3;
+ internal static readonly ushort [] widthCompat =
+ Uni.widthCompat;
+ internal static readonly CodePointIndexer categoryIndexer =
+ UUtil.Category;
+ internal static readonly CodePointIndexer lv1Indexer =
+ UUtil.Category;
+ internal static readonly CodePointIndexer lv2Indexer =
+ UUtil.Category;
+ internal static readonly CodePointIndexer lv3Indexer =
+ UUtil.Category;
+ internal static readonly CodePointIndexer widthIndexer =
+ UUtil.Category;
+
+
SortKeyBuffer buf;
// CompareOptions expanded.
bool ignoreNonSpace; // used in IndexOf()
@@ -301,31 +325,32 @@
byte Category (int cp)
{
if (cp < 0x3000 || cjkTable == null)
- return Uni.Categories (cp);
+ return categories [categoryIndexer.ToIndex
(cp)];
int idx = cjkIndexer.ToIndex (cp);
ushort cjk = idx < 0 ? (ushort) 0 : cjkTable [idx];
return cjk != 0 ? (byte) ((cjk & 0xFF00) >> 8) :
- Uni.Categories (cp);
+ categories [categoryIndexer.ToIndex (cp)];
}
byte Level1 (int cp)
{
if (cp < 0x3000 || cjkTable == null)
- return Uni.Level1 (cp);
+ return level1 [lv1Indexer.ToIndex (cp)];
int idx = cjkIndexer.ToIndex (cp);
ushort cjk = idx < 0 ? (ushort) 0 : cjkTable [idx];
- return cjk != 0 ? (byte) (cjk & 0xFF) : Uni.Level1 (cp);
+ return cjk != 0 ? (byte) (cjk & 0xFF) :
+ level1 [lv1Indexer.ToIndex (cp)];
}
byte Level2 (int cp)
{
if (cp < 0x3000 || cjkLv2Table == null)
- return Uni.Level2 (cp);
+ return level2 [lv2Indexer.ToIndex (cp)];
int idx = cjkLv2Indexer.ToIndex (cp);
byte ret = idx < 0 ? (byte) 0 : cjkLv2Table [idx];
if (ret != 0)
return ret;
- ret = Uni.Level2 (cp);
+ ret = level2 [lv2Indexer.ToIndex (cp)];
if (level2Maps.Length == 0)
return ret;
for (int i = 0; i < level2Maps.Length; i++) {
@@ -428,7 +453,7 @@
int FilterOptions (int i)
{
if (ignoreWidth)
- i = Uni.ToWidthCompat (i);
+ i = widthCompat [widthIndexer.ToIndex (i)];
if (ignoreCase)
i = textInfo.ToLower ((char) i);
if (ignoreKanaType)
@@ -476,7 +501,7 @@
b [0],
b [1],
b [2] != 1 ? b [2] :
Level2 (i),
- b [3] != 1 ? b [3] :
Uni.Level3 (i));
+ b [3] != 1 ? b [3] :
level3 [lv3Indexer.ToIndex (i)]);
}
n += ct.Source.Length - 1;
}
@@ -617,9 +642,11 @@
return 0;
// FIXME: this should be done inside Compare() at
// any time.
- int ord = CompareOrdinal (s1, idx1, len1, s2, idx2,
len2);
- if (ord == 0 || options == CompareOptions.Ordinal)
- return ord;
+// int ord = CompareOrdinal (s1, idx1, len1, s2, idx2,
len2);
+// if (ord == 0)
+// return 0;
+ if (options == CompareOptions.Ordinal)
+ return CompareOrdinal (s1, idx1, len1, s2,
idx2, len2);
#if false // stable easy version, depends on GetSortKey().
SortKey sk1 = GetSortKey (s1, idx1, len1, options);
@@ -664,8 +691,6 @@
int lv5Value2 = 0;
while (true) {
- int cur1 = idx1;
- int cur2 = idx2;
if (idx1 >= end1) {
if (escape1.Source == null)
break;
@@ -684,28 +709,32 @@
end2 = escape2.End;
escape2.Source = null;
}
-/* FIXME: optimization could be done here.
+#if false
+// FIXME: optimization could be done here.
if (s1 [idx1] == s2 [idx2]) {
idx1++;
idx2++;
continue;
}
- while (idx1 >= start1 && !IsSafe ((int) s
[idx1]))
- idx1--;
- while (idx2 >= start2 && !IsSafe ((int) s
[idx2]))
- idx2--;
-*/
+// while (idx1 >= start1 && !IsSafe ((int) s
[idx1]))
+// idx1--;
+// while (idx2 >= start2 && !IsSafe ((int) s
[idx2]))
+// idx2--;
+#endif
+ int cur1 = idx1;
+ int cur2 = idx2;
byte [] sk1 = null;
byte [] sk2 = null;
int i1 = FilterOptions (s1 [idx1]);
int i2 = FilterOptions (s2 [idx2]);
bool special1 = false;
bool special2 = false;
+ byte cat1 = Category (i1);
// Handle special weight characters
- if (!stringSort && Category (i1) == 6) {
+ if (!stringSort && cat1 == 6) {
lv5At1 = escape1.Source != null ?
escape1.Index - escape1.Start :
cur1 - start1;
@@ -715,7 +744,10 @@
idx1++;
continue;
}
- if (!stringSort && Category (i2) == 6) {
+
+ byte cat2 = Category (i2);
+
+ if (!stringSort && cat2 == 6) {
lv5At2 = escape2.Source != null ?
escape2.Index - escape2.Start :
cur2 - start2;
@@ -745,7 +777,7 @@
}
else {
sk1 = charSortKey;
- sk1 [0] = Category (i1);
+ sk1 [0] = cat1;
sk1 [1] = Level1 (i1);
if (!ignoreNonSpace && currentLevel > 1)
sk1 [2] = Level2 (i1);
@@ -783,7 +815,7 @@
}
else {
sk2 = charSortKey2;
- sk2 [0] = Category (i2);
+ sk2 [0] = cat2;
sk2 [1] = Level1 (i2);
if (!ignoreNonSpace && currentLevel > 1)
sk2 [2] = Level2 (i2);
Modified:
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
===================================================================
---
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
2005-07-05 12:49:40 UTC (rev 46942)
+++
trunk/mcs/class/corlib/Mono.Globalization.Unicode/create-mscompat-collation-table.cs
2005-07-05 12:54:04 UTC (rev 46943)
@@ -321,7 +321,7 @@
MSCompatUnicodeTableUtil.Cjk);
// Ignorables
- Result.WriteLine ("static byte [] ignorableFlags = new
byte [] {");
+ Result.WriteLine ("internal static readonly byte []
ignorableFlags = new byte [] {");
#if Binary
MemoryStream ms = new MemoryStream ();
BinaryWriter binary = new BinaryWriter (ms);
@@ -343,7 +343,7 @@
Result.WriteLine ();
// Primary category
- Result.WriteLine ("static byte [] categories = new byte
[] {");
+ Result.WriteLine ("internal static readonly byte []
categories = new byte [] {");
#if Binary
binary.Write (categories.Length);
#endif
@@ -363,7 +363,7 @@
Result.WriteLine ();
// Primary weight value
- Result.WriteLine ("static byte [] level1 = new byte []
{");
+ Result.WriteLine ("internal static readonly byte []
level1 = new byte [] {");
#if Binary
binary.Write (level1.Length);
#endif
@@ -383,7 +383,7 @@
Result.WriteLine ();
// Secondary weight
- Result.WriteLine ("static byte [] level2 = new byte []
{");
+ Result.WriteLine ("internal static readonly byte []
level2 = new byte [] {");
#if Binary
binary.Write (level2.Length);
#endif
@@ -403,7 +403,7 @@
Result.WriteLine ();
// Thirtiary weight
- Result.WriteLine ("static byte [] level3 = new byte []
{");
+ Result.WriteLine ("internal static readonly byte []
level3 = new byte [] {");
#if Binary
binary.Write (level3.Length);
#endif
@@ -425,7 +425,7 @@
// Width insensitivity mappings
// (for now it is more lightweight than dumping the
// entire NFKD table).
- Result.WriteLine ("static ushort [] widthCompat = new
ushort [] {");
+ Result.WriteLine ("internal static readonly ushort []
widthCompat = new ushort [] {");
#if Binary
binary.Write (widthCompat.Length);
#endif
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches