mirror of
https://github.com/python/cpython.git
synced 2025-09-15 13:16:12 +00:00
GH-96458: Statically initialize utf8 representation of static strings (#96481)
This commit is contained in:
parent
16c6759b37
commit
6dab8c95bd
6 changed files with 139 additions and 165 deletions
|
@ -195,7 +195,6 @@ class Printer:
|
|||
else:
|
||||
self.write("PyCompactUnicodeObject _compact;")
|
||||
self.write(f"{datatype} _data[{len(s)+1}];")
|
||||
self.deallocs.append(f"_PyStaticUnicode_Dealloc((PyObject *)&{name});")
|
||||
with self.block(f"{name} =", ";"):
|
||||
if ascii:
|
||||
with self.block("._ascii =", ","):
|
||||
|
@ -218,6 +217,9 @@ class Printer:
|
|||
self.write(f".kind = {kind},")
|
||||
self.write(".compact = 1,")
|
||||
self.write(".ascii = 0,")
|
||||
utf8 = s.encode('utf-8')
|
||||
self.write(f'.utf8 = {make_string_literal(utf8)},')
|
||||
self.write(f'.utf8_length = {len(utf8)},')
|
||||
with self.block(f"._data =", ","):
|
||||
for i in range(0, len(s), 16):
|
||||
data = s[i:i+16]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue