mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
mmapmodule: Use SetFileInformationByHandle instead of SetFilePointerEx
This trades two windows syscalls with one.
This commit is contained in:
parent
7099af8f5e
commit
cec855dd98
1 changed files with 6 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue