8000 Address code review · python/cpython@f30b355 · GitHub
[go: up one dir, main page]

Skip to content

Commit f30b355

Browse files
committed
Address code review
1 parent 45536d0 commit f30b355

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Include/cpython/unicodeobject.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ typedef struct {
108108
3: Interned, Immortal, and Static
109109
This categorization allows the runtime to determine the right
110110
cleanup mechanism at runtime shutdown. */
111-
uint16_t interned;
111+
uint8_t interned;
112112
struct {
113113
/* Character size:
114114
@@ -132,21 +132,21 @@ typedef struct {
132132
* all characters are in the range U+0000-U+10FFFF
133133
* at least one character is in the range U+10000-U+10FFFF
134134
*/
135-
uint16_t kind:3;
135+
unsigned int kind:3;
136136
/* Compact is with respect to the allocation scheme. Compact unicode
137137
objects only require one memory block while non-compact objects use
138138
one block for the PyUnicodeObject struct and another for its data
139139
buffer. */
140-
uint16_t compact:1;
140+
unsigned int compact:1;
141141
/* The string only contains characters in the range U+0000-U+007F (ASCII)
142142
and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is
143143
set, use the PyASCIIObject structure. */
144-
uint16_t ascii:1;
144+
unsigned int ascii:1;
145145
/* The object is statically allocated. */
146-
uint16_t statically_allocated:1;
146+
unsigned int statically_allocated:1;
147147
/* Padding to ensure that PyUnicode_DATA() is always aligned to
148148
4 bytes (see issue #19537 on m68k). */
149-
uint16_t :10;
149+
unsigned int :10;
150150
} state;
151151
} PyASCIIObject;
152152

@@ -196,7 +196,7 @@ typedef struct {
196196
/* Use only if you know it's a string */
197197
static inline unsigned int PyUnicode_CHECK_INTERNED(PyObject *op) {
198198
#ifdef Py_GIL_DISABLED
199-
return _Py_atomic_load_uint16_relaxed(&(_PyASCIIObject_CAST(op)->interned));
199+
return _Py_atomic_load_uint8_relaxed(&(_PyASCIIObject_CAST(op)->interned));
200200
#else
201201
return _PyASCIIObject_CAST(op)->interned;
202202
#endif

Objects/unicodeobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15726,7 +15726,7 @@ immortalize_interned(PyObject *s)
1572615726
_Py_DecRefTotal(_PyThreadState_GET());
1572715727
}
1572815728
#endif
15729-
FT_ATOMIC_STORE_UINT16_RELAXED(_PyASCIIObject_CAST(s)->interned, SSTATE_INTERNED_IMMORTAL);
15729+
FT_ATOMIC_STORE_UINT8_RELAXED(_PyASCIIObject_CAST(s)->interned, SSTATE_INTERNED_IMMORTAL);
1573015730
_Py_SetImmortal(s);
1573115731
}
1573215732

@@ -15845,7 +15845,7 @@ intern_common(PyInterpreterState *interp, PyObject *s /* stolen */,
1584515845
_Py_DecRefTotal(_PyThreadState_GET());
1584615846
#endif
1584715847
}
15848-
FT_ATOMIC_STORE_UINT16_RELAXED(_PyASCIIObject_CAST(s)->interned, SSTATE_INTERNED_MORTAL);
15848+
FT_ATOMIC_STORE_UINT8_RELAXED(_PyASCIIObject_CAST(s)->interned, SSTATE_INTERNED_MORTAL);
1584915849

1585015850
/* INTERNED_MORTAL -> INTERNED_IMMORTAL (if needed) */
1585115851

@@ -15981,7 +15981,7 @@ _PyUnicode_ClearInterned(PyInterpreterState *interp)
1598115981
Py_UNREACHABLE();
1598215982
}
1598315983
if (!shared) {
15984-
FT_ATOMIC_STORE_UINT16_RELAXED(_PyASCIIObject_CAST(s)->interned, SSTATE_NOT_INTERNED);
15984+
FT_ATOMIC_STORE_UINT8_RELAXED(_PyASCIIObject_CAST(s)->interned, SSTATE_NOT_INTERNED);
1598515985
}
1598615986
}
1598715987
#ifdef INTERNED_STATS

0 commit comments

Comments
 (0)
0