@@ -143,20 +143,9 @@ void Module::RequireCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
143
143
// cache the required modules by full path, not name only, since there might be some collisions with relative paths and names
144
144
string modulePath = ArgConverter::jstringToString ((jstring) jsModulePath);
145
145
146
- auto it = s_loadedModules.find (modulePath);
147
-
148
- Local<Object> moduleObj;
149
-
150
146
auto isData = false ;
151
147
152
- if (it == s_loadedModules.end ())
153
- {
154
- moduleObj = Load (modulePath, isData);
155
- }
156
- else
157
- {
158
- moduleObj = Local<Object>::New (isolate, *it->second );
159
- }
148
+ auto moduleObj = Load (modulePath, isData);
160
149
161
150
if (isData)
162
151
{
@@ -202,20 +191,30 @@ Local<Object> Module::Load(const string& path, bool& isData)
202
191
203
192
auto isolate = Isolate::GetCurrent ();
204
193
205
- if (Util::EndsWith (path, " .js" ) || Util::EndsWith (path, " .so" ))
206
- {
207
- isData = false ;
208
- result = LoadModule (isolate, path);
209
- }
210
- else if (Util::EndsWith (path, " .json" ))
194
+ auto it = s_loadedModules.find (path);
195
+
196
+ if (it == s_loadedModules.end ())
211
197
{
212
- isData = true ;
213
- result = LoadData (isolate, path);
198
+ if (Util::EndsWith (path, " .js" ) || Util::EndsWith (path, " .so" ))
199
+ {
200
+ isData = false ;
201
+ result = LoadModule (isolate, path);
202
+ }
203
+ else if (Util::EndsWith (path, " .json" ))
204
+ {
205
+ isData = true ;
206
+ result = LoadData (isolate, path);
207
+ }
208
+ else
209
+ {
210
+ string errMsg = " Unsupported file extension: " + path;
211
+ throw NativeScriptException (errMsg);
212
+ }
214
213
}
215
214
else
216
215
{
217
- string errMsg = " Unsupported file extension: " + path ;
218
- throw NativeScriptException (errMsg );
216
+ isData = Util::EndsWith (path, " .json " ) ;
217
+ result = Local<Object>:: New (isolate, *it-> second );
219
218
}
220
219
221
220
return result;
0 commit comments