Init: don't pay for unused module

Networking can be very slow
This commit is contained in:
李通洲
2022-09-29 17:14:50 +08:00
parent 9cf95620a9
commit 8a52836afc
3 changed files with 17 additions and 4 deletions
+13
View File
@@ -1485,6 +1485,19 @@ int main(int argc, const char** argv)
if(data.structure.length == 0)
ffStrbufAppendS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
#define FF_CONTAINS_MODULE_NAME(moduleName)\
ffStrbufContainIgnCaseS(&data.structure, ":" #moduleName ":") ||\
ffStrbufStartsWithIgnCaseS(&data.structure, #moduleName ":") ||\
ffStrbufEndsWithIgnCaseS(&data.structure, ":" #moduleName)
if(FF_CONTAINS_MODULE_NAME(CPUUsage))
ffPrepareCPUUsage();
if(FF_CONTAINS_MODULE_NAME(PublicIp))
ffPreparePublicIp(&instance);
if(FF_CONTAINS_MODULE_NAME(Weather))
ffPrepareWeather(&instance);
#undef FF_CONTAINS_MODULE_NAME
ffStart(&instance);
//Parse the structure and call the modules