Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: Source/core/html/parser/create-html-entity-table

Issue 120393003: HTMLEntityTable could use char to reduce binary size (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: For review Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/html/parser/HTMLEntityTable.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2010 Google Inc. All rights reserved. 2 # Copyright (c) 2010 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 24 matching lines...) Expand all
35 ENTITY = 0 35 ENTITY = 0
36 VALUE = 1 36 VALUE = 1
37 37
38 def convert_entity_to_cpp_name(entity): 38 def convert_entity_to_cpp_name(entity):
39 postfix = "EntityName" 39 postfix = "EntityName"
40 if entity[-1] == ";": 40 if entity[-1] == ";":
41 return "%sSemicolon%s" % (entity[:-1], postfix) 41 return "%sSemicolon%s" % (entity[:-1], postfix)
42 return "%s%s" % (entity, postfix) 42 return "%s%s" % (entity, postfix)
43 43
44 44
45 def convert_entity_to_uchar_array(entity):
46 return "{'%s'}" % "', '".join(entity)
47
48
49 def convert_value_to_int(value): 45 def convert_value_to_int(value):
50 if not value: 46 if not value:
51 return "0"; 47 return "0";
52 assert(value[0] == "U") 48 assert(value[0] == "U")
53 assert(value[1] == "+") 49 assert(value[1] == "+")
54 return "0x" + value[2:] 50 return "0x" + value[2:]
55 51
56 52
57 def offset_table_entry(offset): 53 def offset_table_entry(offset):
58 return " &staticEntityTable[%s]," % offset 54 return " &staticEntityTable[%s]," % offset
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 102
107 #include "config.h" 103 #include "config.h"
108 #include "core/html/parser/HTMLEntityTable.h" 104 #include "core/html/parser/HTMLEntityTable.h"
109 105
110 namespace WebCore { 106 namespace WebCore {
111 107
112 namespace { 108 namespace {
113 """) 109 """)
114 110
115 for entry in entries: 111 for entry in entries:
116 output_file.write("static const UChar %s[] = %s;\n" % ( 112 output_file.write("static const LChar %s[] = \"%s\";\n" % (convert_entity_to _cpp_name(entry[ENTITY]), entry[ENTITY]))
117 convert_entity_to_cpp_name(entry[ENTITY]),
118 convert_entity_to_uchar_array(entry[ENTITY])))
119 113
120 output_file.write(""" 114 output_file.write("""
121 static const HTMLEntityTableEntry staticEntityTable[%s] = {\n""" % entity_count) 115 static const HTMLEntityTableEntry staticEntityTable[%s] = {\n""" % entity_count)
122 116
123 index = {} 117 index = {}
124 offset = 0 118 offset = 0
125 for entry in entries: 119 for entry in entries:
126 letter = entry[ENTITY][0] 120 letter = entry[ENTITY][0]
127 if letter not in index: 121 if letter not in index:
128 index[letter] = offset 122 index[letter] = offset
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return &staticEntityTable[0]; 170 return &staticEntityTable[0];
177 } 171 }
178 172
179 const HTMLEntityTableEntry* HTMLEntityTable::lastEntry() 173 const HTMLEntityTableEntry* HTMLEntityTable::lastEntry()
180 { 174 {
181 return &staticEntityTable[%s - 1]; 175 return &staticEntityTable[%s - 1];
182 } 176 }
183 177
184 } 178 }
185 """ % entity_count) 179 """ % entity_count)
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLEntityTable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698