Skip to content

Commit 018ce46

Browse files
committed
Remove rwops fileno code path
BytesIO never has a fileno, and we practically only use this path for BytesIO. So it is redundant code, and slows things down slightly at runtime.
1 parent 5699060 commit 018ce46

File tree

1 file changed

+0
-17
lines changed

1 file changed

+0
-17
lines changed

src_c/rwobject.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ typedef struct {
5353
PyObject *tell;
5454
PyObject *close;
5555
PyObject *file;
56-
int fileno;
5756
} pgRWHelper;
5857

5958
/*static const char pg_default_encoding[] = "unicode_escape";*/
@@ -450,9 +449,6 @@ pgRWops_FromFileObject(PyObject *obj)
450449
if (helper == NULL) {
451450
return (SDL_RWops *)PyErr_NoMemory();
452451
}
453-
helper->fileno = PyObject_AsFileDescriptor(obj);
454-
if (helper->fileno == -1)
455-
PyErr_Clear();
456452
if (fetch_object_methods(helper, obj)) {
457453
PyMem_Free(helper);
458454
return NULL;
@@ -485,10 +481,6 @@ _pg_rw_seek(SDL_RWops *context, Sint64 offset, int whence)
485481
PyObject *result;
486482
Sint64 retval;
487483

488-
if (helper->fileno != -1) {
489-
return PG_LSEEK(helper->fileno, offset, whence);
490-
}
491-
492484
if (!helper->seek || !helper->tell)
493485
return -1;
494486

@@ -533,15 +525,6 @@ _pg_rw_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
533525
PyObject *result;
534526
Py_ssize_t retval;
535527

536-
if (helper->fileno != -1) {
537-
retval = read(helper->fileno, ptr, (unsigned int)(size * maxnum));
538-
if (retval == -1) {
539-
return -1;
540-
}
541-
retval /= size;
542-
return retval;
543-
}
544-
545528
if (!helper->read)
546529
return -1;
547530

0 commit comments

Comments
 (0)