mmapmodule: Use SetFileInformationByHandle instead of SetFilePointerEx

This trades two windows syscalls with one.
This commit is contained in:
AZero13 2025-12-07 23:37:42 -05:00
parent 7099af8f5e
commit cec855dd98

View file

@ -906,9 +906,12 @@ mmap_mmap_resize_impl(mmap_object *self, Py_ssize_t new_size)
}; };
self->data = NULL; self->data = NULL;
/* resize the file */ /* resize the file */
if (!SetFilePointerEx(self->file_handle, max_size, NULL, FILE_END_OF_FILE_INFO info;
FILE_BEGIN) || info.EndOfFile = max_size;
!SetEndOfFile(self->file_handle)) { if (!SetFileInformationByHandle(self->file_handle,
FileEndOfFileInfo,
&info,
sizeof(info))) {
/* resizing failed. try to remap the file */ /* resizing failed. try to remap the file */
file_resize_error = GetLastError(); file_resize_error = GetLastError();
max_size.QuadPart = self->size; max_size.QuadPart = self->size;