-
Notifications
You must be signed in to change notification settings - Fork 468
Optimize big stack allocation (move to heap) #3016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -80,18 +80,18 @@ namespace Sass { | |||||||
bool file_exists(const std::string& path) | ||||||||
{ | ||||||||
#ifdef _WIN32 | ||||||||
wchar_t resolved[32768]; | ||||||||
std::vector<wchar_t> resolved(32768); | ||||||||
mgreter marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
// windows unicode filepaths are encoded in utf16 | ||||||||
std::string abspath(join_paths(get_cwd(), path)); | ||||||||
if (!(abspath[0] == '/' && abspath[1] == '/')) { | ||||||||
abspath = "//?/" + abspath; | ||||||||
} | ||||||||
std::wstring wpath(UTF_8::convert_to_utf16(abspath)); | ||||||||
std::replace(wpath.begin(), wpath.end(), '/', '\\'); | ||||||||
DWORD rv = GetFullPathNameW(wpath.c_str(), 32767, resolved, NULL); | ||||||||
DWORD rv = GetFullPathNameW(wpath.c_str(), 32767, &resolved[0], NULL); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be necessary, since GetFullPathNameW will fill the buffer anyway! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This suggestion is to avoid repeating |
||||||||
if (rv > 32767) throw Exception::OperationError("Path is too long"); | ||||||||
if (rv == 0) throw Exception::OperationError("Path could not be resolved"); | ||||||||
DWORD dwAttrib = GetFileAttributesW(resolved); | ||||||||
DWORD dwAttrib = GetFileAttributesW(&resolved[0]); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES && | ||||||||
(!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))); | ||||||||
#else | ||||||||
|
@@ -437,18 +437,18 @@ namespace Sass { | |||||||
#ifdef _WIN32 | ||||||||
BYTE* pBuffer; | ||||||||
DWORD dwBytes; | ||||||||
wchar_t resolved[32768]; | ||||||||
std::vector<wchar_t> resolved(32768); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
// windows unicode filepaths are encoded in utf16 | ||||||||
std::string abspath(join_paths(get_cwd(), path)); | ||||||||
if (!(abspath[0] == '/' && abspath[1] == '/')) { | ||||||||
abspath = "//?/" + abspath; | ||||||||
} | ||||||||
std::wstring wpath(UTF_8::convert_to_utf16(abspath)); | ||||||||
std::replace(wpath.begin(), wpath.end(), '/', '\\'); | ||||||||
DWORD rv = GetFullPathNameW(wpath.c_str(), 32767, resolved, NULL); | ||||||||
DWORD rv = GetFullPathNameW(wpath.c_str(), 32767, &resolved[0], NULL); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
if (rv > 32767) throw Exception::OperationError("Path is too long"); | ||||||||
if (rv == 0) throw Exception::OperationError("Path could not be resolved"); | ||||||||
HANDLE hFile = CreateFileW(resolved, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); | ||||||||
HANDLE hFile = CreateFileW(&resolved[0], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
if (hFile == INVALID_HANDLE_VALUE) return 0; | ||||||||
DWORD dwFileLength = GetFileSize(hFile, NULL); | ||||||||
if (dwFileLength == INVALID_FILE_SIZE) return 0; | ||||||||
|
Uh oh!
There was an error while loading. Please reload this page.