Enlightenment CVS committal
Author : tilman
Project : e17
Module : libs/evas
Dir : e17/libs/evas/src/lib/canvas
Modified Files:
evas_object_textblock.c
Log Message:
rework how the html entity escape arrays are stored. this saves a few hundred
bytes on the data section of the library, kills off ~300 locations, and makes
the so 77K smaller.
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_object_textblock.c,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -3 -r1.137 -r1.138
--- evas_object_textblock.c 15 May 2007 19:19:00 -0000 1.137
+++ evas_object_textblock.c 17 May 2007 22:48:48 -0000 1.138
@@ -441,190 +441,235 @@
}
/* table of html escapes (that i can find) this should be ordered with the
- * most common first as it's a linear search to match - no hash for this
+ * most common first as it's a linear search to match - no hash for this.
+ *
+ * these are stored as one large string and one additional array that
+ * contains the offsets to the tokens for space efficiency.
*/
-static const char *_escapes[] =
-{
-/* most common escaped stuff */
- "<", "<",
- ">", ">",
- "&", "&",
- " ", " ", /* NOTE: we will allow nbsp's to break as we map early -
maybe map to ascii 0x01 and then make the rendering code think 0x01 -> 0x20 */
- """, "\"",
- /* all the rest */
- "©", "©",
- "®", "®",
- "…", "â¦",
- "Ñ", "Ã",
- "ñ", "ñ",
- "Ç", "Ã",
- "ç", "ç",
- "ß", "Ã",
- "Þ", "Ã",
- "þ", "þ",
- "Ð", "Ã",
- "ð", "ð",
- "´", "´",
- "¸", "¸",
- "°", "°",
- "¨", "¨",
- "¢", "¢",
- "£", "£",
- "¤", "¤",
- "¥", "Â¥",
- "€", "â¬",
- "§", "§",
- "¶", "¶",
- "«", "«",
- "»", "»",
- "¡", "¡",
- "¿", "¿",
- "¦", "¦",
- "ª", "ª",
- "º", "º",
- "µ", "µ",
- "¯", "¯",
- "⊕", "â",
- "∫", "â«",
- "∑", "â",
- "∏", "â",
- "⊥", "â¥",
- "∨", "â¨",
- "∧", "â§",
- "≡", "â¡",
- "≠", "â ",
- "∀", "â",
- "∃", "â",
- "∇", "â",
- "←", "â",
- "→", "â",
- "↑", "â",
- "↓", "â",
- "↔", "â",
- "⇐", "â",
- "⇒", "â",
- "±", "±",
- "·", "·",
- "×", "Ã",
- "÷", "÷",
- "¹", "¹",
- "²", "²",
- "³", "³",
- "¼", "¼",
- "½", "½",
- "¾", "¾",
- "¬", "¬",
- "Á", "Ã",
- "É", "Ã",
- "Í", "Ã",
- "Ó", "Ã",
- "Ú", "Ã",
- "Ý", "Ã",
- "á", "á",
- "é", "é",
- "í", "Ã",
- "ó", "ó",
- "ú", "ú",
- "ý", "ý",
- "Â", "Ã",
- "Ê", "Ã",
- "Î", "Ã",
- "Ô", "Ã",
- "Û", "Ã",
- "â", "â",
- "ê", "ê",
- "î", "î",
- "ô", "ô",
- "û", "û",
- "À", "Ã",
- "È", "Ã",
- "Ì", "Ã",
- "Ò", "Ã",
- "Ù", "Ã",
- "à", "Ã ",
- "è", "è",
- "ì", "ì",
- "ò", "ò",
- "ù", "ù",
- "Ä", "Ã",
- "Ë", "Ã",
- "Ï", "Ã",
- "Ö", "Ã",
- "ä", "ä",
- "ë", "ë",
- "ï", "ï",
- "ö", "ö",
- "ü", "ü",
- "ÿ", "ÿ",
- "Ã", "Ã",
- "ã", "ã",
- "Õ", "Ã",
- "õ", "õ",
- "å", "Ã¥",
- "Å", "Ã
",
- "Ø", "Ã",
- "ø", "ø",
- "Æ", "Ã",
- "æ", "æ",
- "Ñ", "Ã",
- "ñ", "ñ",
- "Ç", "Ã",
- "ç", "ç",
- "ß", "Ã",
- "Þ", "Ã",
- "þ", "þ",
- "Ð", "Ã",
- "ð", "ð",
- "α", "α",
- "β", "β",
- "γ", "γ",
- "δ", "δ",
- "ε", "ε",
- "ζ", "ζ",
- "η", "η",
- "θ", "θ",
- "ι", "ι",
- "κ", "κ",
- "λ", "λ",
- "μ", "μ",
- "ν", "ν",
- "ο", "ο",
- "ξ", "ξ",
- "π", "Ï",
- "ρ", "Ï",
- "σ", "Ï",
- "τ", "Ï",
- "υ", "Ï
",
- "φ", "Ï",
- "χ", "Ï",
- "ψ", "Ï",
- "ω", "Ï",
- "Α", "Î",
- "Β", "Î",
- "Γ", "Î",
- "Δ", "Î",
- "Ε", "Î",
- "Ζ", "Î",
- "Η", "Î",
- "Θ", "Î",
- "Ι", "Î",
- "Κ", "Î",
- "Λ", "Î",
- "Μ", "Î",
- "Ν", "Î",
- "Ο", "Î",
- "Ξ", "Î",
- "Π", "Î ",
- "Ρ", "Ρ",
- "Σ", "Σ",
- "Τ", "Τ",
- "Υ", "Î¥",
- "Φ", "Φ",
- "Χ", "Χ",
- "Ψ", "Ψ",
- "Ω", "Ω"
+static const char escape_strings[] =
+ /* most common escaped stuff */
+ "<\0\x3c\0"
+ ">\0\x3e\0"
+ "&\0\x26\0"
+ " \0\x20\0" /* NOTE: we allow nsbp's to break as we map early -
maybe map to ascii 0x01 and then make the rendering code think 0x01 -> 0x20 */
+ ""\0\x22\0"
+ /* all the rest */
+ "©\0\xc2\xa9\0"
+ "®\0\xc2\xae\0"
+ "…\0\xe2\x80\xa6\0"
+ "Ñ\0\xc3\x91\0"
+ "ñ\0\xc3\xb1\0"
+ "Ç\0\xc3\x87\0"
+ "ç\0\xc3\xa7\0"
+ "ß\0\xc3\x9f\0"
+ "Þ\0\xc3\x9e\0"
+ "þ\0\xc3\xbe\0"
+ "Ð\0\xc3\x90\0"
+ "ð\0\xc3\xb0\0"
+ "´\0\xc2\xb4\0"
+ "¸\0\xc2\xb8\0"
+ "°\0\xc2\xb0\0"
+ "¨\0\xc2\xa8\0"
+ "¢\0\xc2\xa2\0"
+ "£\0\xc2\xa3\0"
+ "¤\0\xc2\xa4\0"
+ "¥\0\xc2\xa5\0"
+ "€\0\xe2\x82\xac\0"
+ "§\0\xc2\xa7\0"
+ "¶\0\xc2\xb6\0"
+ "«\0\xc2\xab\0"
+ "»\0\xc2\xbb\0"
+ "¡\0\xc2\xa1\0"
+ "¿\0\xc2\xbf\0"
+ "¦\0\xc2\xa6\0"
+ "ª\0\xc2\xaa\0"
+ "º\0\xc2\xba\0"
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ξ\0\xce\xbe\0"
+ "π\0\xcf\x80\0"
+ "ρ\0\xcf\x81\0"
+ "σ\0\xcf\x83\0"
+ "τ\0\xcf\x84\0"
+ "υ\0\xcf\x85\0"
+ "φ\0\xcf\x86\0"
+ "χ\0\xcf\x87\0"
+ "ψ\0\xcf\x88\0"
+ "ω\0\xcf\x89\0"
+ "Α\0\xce\x91\0"
+ "Β\0\xce\x92\0"
+ "Γ\0\xce\x93\0"
+ "Δ\0\xce\x94\0"
+ "Ε\0\xce\x95\0"
+ "Ζ\0\xce\x96\0"
+ "Η\0\xce\x97\0"
+ "Θ\0\xce\x98\0"
+ "Ι\0\xce\x99\0"
+ "Κ\0\xce\x9a\0"
+ "Λ\0\xce\x9b\0"
+ "Μ\0\xce\x9c\0"
+ "Ν\0\xce\x9d\0"
+ "Ο\0\xce\x9f\0"
+ "Ξ\0\xce\x9e\0"
+ "Π\0\xce\xa0\0"
+ "Ρ\0\xce\xa1\0"
+ "Σ\0\xce\xa3\0"
+ "Τ\0\xce\xa4\0"
+ "Υ\0\xce\xa5\0"
+ "Φ\0\xce\xa6\0"
+ "Χ\0\xce\xa7\0"
+ "Ψ\0\xce\xa8\0"
+ "Ω\0\xce\xa9\0"
+;
+
+static const unsigned short escape_offsets[] = {
+ 0, 4, 5, 9, 10, 15, 16, 22, 23, 29, 30, 36,
+ 38, 43, 45, 53, 56, 64, 66, 74, 76, 84, 86,
+ 94, 96, 103, 105, 112, 114, 121, 123, 128, 130,
+ 135, 137, 144, 146, 153, 155, 160, 162, 167,
+ 169, 175, 177, 184, 186, 194, 196, 201, 203,
+ 209, 212, 218, 220, 226, 228, 235, 237, 244,
+ 246, 253, 255, 263, 265, 273, 275, 281, 283,
+ 289, 291, 298, 300, 306, 308, 315, 318, 323,
+ 326, 331, 334, 340, 343, 349, 352, 356, 359,
+ 364, 367, 374, 377, 381, 384, 392, 395, 402,
+ 405, 412, 415, 421, 424, 430, 433, 439, 442,
+ 448, 451, 457, 460, 466, 469, 475, 478, 486,
+ 488, 496, 498, 505, 507, 515, 517, 523, 525,
+ 531, 533, 539, 541, 549, 551, 559, 561, 569,
+ 571, 576, 578, 586, 588, 596, 598, 606, 608,
+ 616, 618, 626, 628, 636, 638, 646, 648, 656,
+ 658, 666, 668, 676, 678, 686, 688, 696, 698,
+ 705, 707, 714, 716, 723, 725, 732, 734, 741,
+ 743, 750, 752, 759, 761, 768, 770, 777, 779,
+ 786, 788, 796, 798, 806, 808, 816, 818, 826,
+ 828, 836, 838, 846, 848, 856, 858, 866, 868,
+ 876, 878, 886, 888, 894, 896, 902, 904, 910,
+ 912, 918, 920, 926, 928, 934, 936, 942, 944,
+ 950, 952, 958, 960, 966, 968, 976, 978, 986,
+ 988, 996, 998, 1006, 1008, 1015, 1017, 1024, 1026,
+ 1034, 1036, 1044, 1046, 1053, 1055, 1062, 1064, 1072,
+ 1074, 1082, 1084, 1092, 1094, 1102, 1104, 1111, 1113,
+ 1120, 1122, 1129, 1131, 1136, 1138, 1143, 1145, 1152,
+ 1154, 1160, 1162, 1169, 1171, 1178, 1180, 1189, 1191,
+ 1197, 1199, 1204, 1206, 1213, 1215, 1221, 1223, 1230,
+ 1232, 1240, 1242, 1246, 1248, 1252, 1254, 1263, 1265,
+ 1269, 1271, 1275, 1277, 1282, 1284, 1291, 1293, 1298,
+ 1300, 1309, 1311, 1316, 1318, 1323, 1325, 1330, 1332,
+ 1339, 1341, 1348, 1350, 1356, 1358, 1365, 1367, 1374,
+ 1376, 1385, 1387, 1393, 1395, 1400, 1402, 1409, 1411,
+ 1417, 1419, 1426, 1428, 1436, 1438, 1442, 1444, 1448,
+ 1450, 1459, 1461, 1465, 1467, 1471, 1473, 1478, 1480,
+ 1487, 1489, 1494, 1496, 1505, 1507, 1512, 1514, 1519,
+ 1521, 1526, 1528, 1535
};
+
static int
_is_white(int c)
{
@@ -2492,12 +2537,14 @@
{
int i;
- for (i = 0; i < (int)(sizeof(_escapes) / sizeof(char
*)); i += 2)
+ for (i = 0; i < (int)(sizeof(escape_offsets) /
sizeof(escape_offsets[0])); i += 2)
{
- if (!strncmp(_escapes[i], esc_start,
- esc_end - esc_start + 1))
+ const char *in = escape_strings + escape_offsets[i];
+ const char *out = escape_strings + escape_offsets[i
+ 1];
+
+ if (!strncmp(in, esc_start, esc_end - esc_start +
1))
{
- evas_textblock_cursor_text_append(o->cursor,
_escapes[i + 1]);
+ evas_textblock_cursor_text_append(o->cursor,
out);
break;
}
}
@@ -2595,19 +2642,21 @@
{
int i;
- for (i = 1; i < (int)(sizeof(_escapes) /
sizeof(char *)); i += 2)
+ for (i = 1; i < (int)(sizeof(escape_offsets) /
sizeof(escape_offsets[0])); i += 2)
{
- if (!strncmp(_escapes[i], p,
- strlen(_escapes[i])))
+ const char *in = escape_strings + escape_offsets[i];
+ const char *out = escape_strings + escape_offsets[i
- 1];
+
+ if (!strncmp(in, p, strlen(in)))
{
o->markup_text =
_strbuf_append_n(o->markup_text,
ps, p -
ps,
&slen,
&salloc);
o->markup_text =
_strbuf_append(o->markup_text,
-
_escapes[i-1],
+ out,
&slen,
&salloc);
- ps = p + strlen(_escapes[i]);
- p += strlen(_escapes[i]) - 1;
+ ps = p + strlen(in);
+ p += strlen(in) - 1;
}
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs