From cec855dd98db326f835389b585e7a09ccba216b7 Mon Sep 17 00:00:00 2001 From: AZero13 Date: Sun, 7 Dec 2025 23:37:42 -0500 Subject: [PATCH] mmapmodule: Use SetFileInformationByHandle instead of SetFilePointerEx This trades two windows syscalls with one. --- Modules/mmapmodule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index ac8521f8aa9b6e..1a64cc34e181e7 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -906,9 +906,12 @@ mmap_mmap_resize_impl(mmap_object *self, Py_ssize_t new_size) }; self->data = NULL; /* resize the file */ - if (!SetFilePointerEx(self->file_handle, max_size, NULL, - FILE_BEGIN) || - !SetEndOfFile(self->file_handle)) { + FILE_END_OF_FILE_INFO info; + info.EndOfFile = max_size; + if (!SetFileInformationByHandle(self->file_handle, + FileEndOfFileInfo, + &info, + sizeof(info))) { /* resizing failed. try to remap the file */ file_resize_error = GetLastError(); max_size.QuadPart = self->size;