Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
PyPy
pypy
Commits
195ceabd426e
Commit
7a092439
authored
Oct 30, 2019
by
Armin Rigo
Browse files
Don't allocate a small list here
parent
b50c4326c73f
Changes
1
Hide whitespace changes
Inline
Side-by-side
pypy/interpreter/unicodehelper.py
View file @
195ceabd
...
...
@@ -1184,9 +1184,9 @@ def str_decode_utf_32_helper(s, errors, final,
size
=
len
(
s
)
if
BYTEORDER
==
'little'
:
iorder
=
[
0
,
1
,
2
,
3
]
iorder
0
,
iorder1
,
iorder2
,
iorder3
=
0
,
1
,
2
,
3
else
:
iorder
=
[
3
,
2
,
1
,
0
]
iorder
0
,
iorder1
,
iorder2
,
iorder3
=
3
,
2
,
1
,
0
# Check for BOM marks (U+FEFF) in the input and adjust current
# byte order setting accordingly. In native mode, the leading BOM
...
...
@@ -1196,8 +1196,8 @@ def str_decode_utf_32_helper(s, errors, final,
if
byteorder
==
'native'
:
if
size
>=
4
:
bom
=
intmask
(
(
ord
(
s
[
iorder
[
3
]
])
<<
24
)
|
(
ord
(
s
[
iorder
[
2
]
])
<<
16
)
|
(
ord
(
s
[
iorder
[
1
]
])
<<
8
)
|
ord
(
s
[
iorder
[
0
]
]))
(
ord
(
s
[
iorder
3
])
<<
24
)
|
(
ord
(
s
[
iorder
2
])
<<
16
)
|
(
ord
(
s
[
iorder
1
])
<<
8
)
|
ord
(
s
[
iorder
0
]))
if
BYTEORDER
==
'little'
:
if
bom
==
BOM32_DIRECT
:
pos
+=
4
...
...
@@ -1220,10 +1220,10 @@ def str_decode_utf_32_helper(s, errors, final,
return
''
,
0
,
0
,
bo
if
bo
==
-
1
:
# force little endian
iorder
=
[
0
,
1
,
2
,
3
]
iorder
0
,
iorder1
,
iorder2
,
iorder3
=
0
,
1
,
2
,
3
elif
bo
==
1
:
# force big endian
iorder
=
[
3
,
2
,
1
,
0
]
iorder
0
,
iorder1
,
iorder2
,
iorder3
=
3
,
2
,
1
,
0
result
=
StringBuilder
(
size
//
4
)
...
...
@@ -1239,8 +1239,8 @@ def str_decode_utf_32_helper(s, errors, final,
if
len
(
s
)
-
pos
<
4
:
break
continue
ch
=
((
ord
(
s
[
pos
+
iorder
[
3
]
])
<<
24
)
|
(
ord
(
s
[
pos
+
iorder
[
2
]
])
<<
16
)
|
(
ord
(
s
[
pos
+
iorder
[
1
]
])
<<
8
)
|
ord
(
s
[
pos
+
iorder
[
0
]
]))
ch
=
((
ord
(
s
[
pos
+
iorder
3
])
<<
24
)
|
(
ord
(
s
[
pos
+
iorder
2
])
<<
16
)
|
(
ord
(
s
[
pos
+
iorder
1
])
<<
8
)
|
ord
(
s
[
pos
+
iorder
0
]))
if
not
allow_surrogates
and
0xD800
<=
ch
<=
0xDFFF
:
r
,
pos
=
errorhandler
(
errors
,
public_encoding_name
,
"code point in surrogate code point "
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment