From 8b7fc0f79142a4babd31221d3bbf1071e2be67d5 Mon Sep 17 00:00:00 2001 From: q66 Date: Thu, 7 Jul 2016 17:06:57 +0100 Subject: [PATCH] don't alloc path twice --- ostd/filesystem.hh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ostd/filesystem.hh b/ostd/filesystem.hh index 12694cc..4a3893b 100644 --- a/ostd/filesystem.hh +++ b/ostd/filesystem.hh @@ -130,14 +130,14 @@ struct FileInfo { private: void init_from_str(ConstCharRange path) { + p_path = path; #ifdef OSTD_PLATFORM_WIN32 WIN32_FILE_ATTRIBUTE_DATA attr; - if (!GetFileAttributesEx(String(path).data(), GetFileExInfoStandard, - &attr) || + if (!GetFileAttributesEx(p_path.data(), GetFileExInfoStandard, &attr) || attr.dwFileAttributes == INVALID_FILE_ATTRIBUTES) #else struct stat st; - if (stat(String(path).data(), &st) < 0) + if (stat(p_path.data(), &st) < 0) #endif { p_slash = p_dot = npos; @@ -146,7 +146,6 @@ private: p_atime = p_mtime = p_ctime = 0; return; } - p_path = path; ConstCharRange r = p_path.iter(); ConstCharRange found = find_last(r, PathSeparator);