diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index 59b01b3b5..8bef6c916 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -1505,6 +1506,15 @@ bool FGNasalSys::loadModule(SGPath file, const char* module) return false; } +#if 1 + // MMap the contents of the file. + // This saves an alloc, memcpy and free + SGMMapFile mmap(file); + mmap.open(SG_IO_IN); + + auto pathStr = file.utf8Str(); + return createModule(module, pathStr.c_str(), mmap.get(), mmap.get_size()); +#else sg_ifstream file_in(file); string buf; while (!file_in.eof()) { @@ -1515,6 +1525,7 @@ bool FGNasalSys::loadModule(SGPath file, const char* module) file_in.close(); auto pathStr = file.utf8Str(); return createModule(module, pathStr.c_str(), buf.data(), buf.length()); +#endif } // Parse and run. Save the local variables namespace, as it will