2
2
// __EXTENSIONS__ fix on Solaris.
3
3
#include " sass.hpp"
4
4
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
+
5
11
#ifdef _WIN32
6
12
# ifdef __MINGW32__
7
13
# ifndef off64_t
@@ -76,18 +82,18 @@ namespace Sass {
76
82
}
77
83
78
84
79
- // static thread_local std::unordered_map<
80
- // sass::string, bool> cached;
85
+ static thread_local std::unordered_map<
86
+ sass::string, bool > cached;
81
87
82
88
// test if path exists and is a file
83
89
// ToDo: Move the cache to context for thread safety
84
90
bool file_exists (const sass::string& path, const sass::string& CWD)
85
91
{
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
+ }
91
97
#ifdef _WIN32
92
98
wchar_t resolved[32768 ];
93
99
// windows unicode filepaths are encoded in utf16
@@ -110,13 +116,13 @@ namespace Sass {
110
116
bool result = (dwAttrib != INVALID_FILE_ATTRIBUTES
111
117
&& (!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)));
112
118
// cached[abspath] = result;
113
- // cached[path] = result;
119
+ cached[path] = result;
114
120
return result;
115
121
#else
116
122
struct stat st_buf;
117
123
bool result = (stat (path.c_str (), &st_buf) == 0 )
118
124
&& (!S_ISDIR (st_buf.st_mode ));
119
- // cached[path] = result;
125
+ cached[path] = result;
120
126
return result;
121
127
#endif
122
128
}
0 commit comments