22// __EXTENSIONS__ fix on Solaris.
33#include " sass.hpp"
44
5+ #if defined (_MSC_VER) // Visual studio
6+ #define thread_local __declspec ( thread )
7+ #elif defined (__GCC__) // GCC
8+ #define thread_local __thread
9+ #endif
10+
511#ifdef _WIN32
612# ifdef __MINGW32__
713# ifndef off64_t
@@ -76,18 +82,18 @@ namespace Sass {
7682 }
7783
7884
79- // static thread_local std::unordered_map<
80- // sass::string, bool> cached;
85+ static thread_local std::unordered_map<
86+ sass::string, bool > cached;
8187
8288 // test if path exists and is a file
8389 // ToDo: Move the cache to context for thread safety
8490 bool file_exists (const sass::string& path, const sass::string& CWD)
8591 {
86- // auto it = cached.find(path);
87- // if (it != cached.end()) {
88- // // std::cerr << "cached reg " << path << "\n";
89- // return it->second;
90- // }
92+ auto it = cached.find (path);
93+ if (it != cached.end ()) {
94+ // std::cerr << "cached reg " << path << "\n";
95+ return it->second ;
96+ }
9197 #ifdef _WIN32
9298 wchar_t resolved[32768 ];
9399 // windows unicode filepaths are encoded in utf16
@@ -110,13 +116,13 @@ namespace Sass {
110116 bool result = (dwAttrib != INVALID_FILE_ATTRIBUTES
111117 && (!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)));
112118 // cached[abspath] = result;
113- // cached[path] = result;
119+ cached[path] = result;
114120 return result;
115121 #else
116122 struct stat st_buf;
117123 bool result = (stat (path.c_str (), &st_buf) == 0 )
118124 && (!S_ISDIR (st_buf.st_mode ));
119- // cached[path] = result;
125+ cached[path] = result;
120126 return result;
121127#endif
122128 }
0 commit comments