Skip to content

Commit cec855d

Browse files
committed
mmapmodule: Use SetFileInformationByHandle instead of SetFilePointerEx
This trades two windows syscalls with one.
1 parent 7099af8 commit cec855d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Modules/mmapmodule.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,12 @@ mmap_mmap_resize_impl(mmap_object *self, Py_ssize_t new_size)
906906
};
907907
self->data = NULL;
908908
/* resize the file */
909-
if (!SetFilePointerEx(self->file_handle, max_size, NULL,
910-
FILE_BEGIN) ||
911-
!SetEndOfFile(self->file_handle)) {
909+
FILE_END_OF_FILE_INFO info;
910+
info.EndOfFile = max_size;
911+
if (!SetFileInformationByHandle(self->file_handle,
912+
FileEndOfFileInfo,
913+
&info,
914+
sizeof(info))) {
912915
/* resizing failed. try to remap the file */
913916
file_resize_error = GetLastError();
914917
max_size.QuadPart = self->size;

0 commit comments

Comments
 (0)