@@ -85,59 +85,6 @@ static inline bool CPyBytesWriter_Check(PyObject *obj) {
8585 return Py_TYPE (obj ) == LibRTStrings_BytesWriter_type_internal ();
8686}
8787
88- static inline bool
89- CPyBytesWriter_EnsureSize (BytesWriterObject * data , Py_ssize_t n ) {
90- if (likely (data -> capacity - data -> len >= n )) {
91- return true;
92- } else {
93- return LibRTStrings_ByteWriter_grow_buffer_internal (data , n );
94- }
95- }
96-
97- static inline char
98- CPyBytesWriter_Append (PyObject * obj , uint8_t value ) {
99- BytesWriterObject * self = (BytesWriterObject * )obj ;
100- // Store length in a local variable to enable additional optimizations
101- Py_ssize_t len = self -> len ;
102- if (!CPyBytesWriter_EnsureSize (self , 1 ))
103- return CPY_NONE_ERROR ;
104- self -> buf [len ] = value ;
105- self -> len = len + 1 ;
106- return CPY_NONE ;
107- }
108-
109- static char
110- CPyBytesWriter_Write (PyObject * obj , PyObject * value ) {
111- BytesWriterObject * self = (BytesWriterObject * )obj ;
112- const char * data ;
113- Py_ssize_t size ;
114- if (likely (PyBytes_Check (value ))) {
115- data = PyBytes_AS_STRING (value );
116- size = PyBytes_GET_SIZE (value );
117- } else {
118- data = PyByteArray_AS_STRING (value );
119- size = PyByteArray_GET_SIZE (value );
120- }
121- // Write bytes content.
122- if (!CPyBytesWriter_EnsureSize (self , size ))
123- return CPY_NONE_ERROR ;
124- if (size < 8 ) {
125- char * p = self -> buf + self -> len ;
126- for (Py_ssize_t i = 0 ; i < size ; i ++ ) {
127- p [i ] = data [i ];
128- }
129- } else {
130- memcpy (self -> buf + self -> len , data , size );
131- }
132- self -> len += size ;
133- return CPY_NONE ;
134- }
135-
136- static inline CPyTagged
137- CPyBytesWriter_Len (PyObject * obj ) {
138- return (CPyTagged )((BytesWriterObject * )obj )-> len << 1 ;
139- }
140-
14188#endif // MYPYC_EXPERIMENTAL
14289
14390#endif // LIBRT_STRINGS_H
0 commit comments