ruby-changes:36313
From: usa <ko1@a...>
Date: Thu, 13 Nov 2014 12:18:06 +0900 (JST)
Subject: [ruby-changes:36313] usa:r48394 (trunk): * rb_w32_fstat{, i64}: speed up. adjuting timestamps in this function
usa 2014-11-13 12:18:00 +0900 (Thu, 13 Nov 2014) New Revision: 48394 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48394 Log: * rb_w32_fstat{,i64}: speed up. adjuting timestamps in this function is to get rid of the side effect of ENV["TZ"]. then, if ENV["TZ"] is not set, no need to adjust. this change makes File#stat about 60% faster. Modified files: trunk/ChangeLog trunk/win32/win32.c Index: ChangeLog =================================================================== --- ChangeLog (revision 48393) +++ ChangeLog (revision 48394) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Nov 13 12:11:18 2014 NAKAMURA Usaku <usa@r...> + + * rb_w32_fstat{,i64}: speed up. adjuting timestamps in this function + is to get rid of the side effect of ENV["TZ"]. then, if ENV["TZ"] is + not set, no need to adjust. this change makes File#stat about 60% + faster. + Thu Nov 13 11:56:12 2014 Nobuyoshi Nakada <nobu@r...> * st.c: include "internal.h" for STATIC_ASSERT. Index: win32/win32.c =================================================================== --- win32/win32.c (revision 48393) +++ win32/win32.c (revision 48394) @@ -4815,6 +4815,8 @@ rb_w32_fstat(int fd, struct stat *st) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4815 if (ret) return ret; #ifdef __BORLANDC__ st->st_mode &= ~(S_IWGRP | S_IWOTH); +#else + if (GetEnvironmentVariableW(L"TZ", NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) return ret; #endif if (GetFileInformationByHandle((HANDLE)_get_osfhandle(fd), &info)) { #ifdef __BORLANDC__ @@ -4835,7 +4837,12 @@ rb_w32_fstati64(int fd, struct stati64 * https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4837 { BY_HANDLE_FILE_INFORMATION info; struct stat tmp; - int ret = fstat(fd, &tmp); + int ret; + +#ifndef __BORLANDC__ + if (GetEnvironmentVariableW(L"TZ", NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) return _fstati64(fd, st); +#endif + ret = fstat(fd, &tmp); if (ret) return ret; #ifdef __BORLANDC__ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/