Skip to content

Commit 8a52836

Browse files
committed
Init: don't pay for unused module
Networking can be very slow
1 parent 9cf9562 commit 8a52836

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/common/init.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,6 @@ static void exitSignalHandler(int signal)
363363

364364
void ffStart(FFinstance* instance)
365365
{
366-
ffPrepareCPUUsage();
367-
ffPreparePublicIp(instance);
368-
ffPrepareWeather(instance);
369-
370366
if(instance->config.multithreading)
371367
startDetectionThreads(instance);
372368

src/fastfetch.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,19 @@ int main(int argc, const char** argv)
14851485
if(data.structure.length == 0)
14861486
ffStrbufAppendS(&data.structure, FASTFETCH_DATATEXT_STRUCTURE);
14871487

1488+
#define FF_CONTAINS_MODULE_NAME(moduleName)\
1489+
ffStrbufContainIgnCaseS(&data.structure, ":" #moduleName ":") ||\
1490+
ffStrbufStartsWithIgnCaseS(&data.structure, #moduleName ":") ||\
1491+
ffStrbufEndsWithIgnCaseS(&data.structure, ":" #moduleName)
1492+
1493+
if(FF_CONTAINS_MODULE_NAME(CPUUsage))
1494+
ffPrepareCPUUsage();
1495+
if(FF_CONTAINS_MODULE_NAME(PublicIp))
1496+
ffPreparePublicIp(&instance);
1497+
if(FF_CONTAINS_MODULE_NAME(Weather))
1498+
ffPrepareWeather(&instance);
1499+
#undef FF_CONTAINS_MODULE_NAME
1500+
14881501
ffStart(&instance);
14891502

14901503
//Parse the structure and call the modules

src/flashfetch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ int main(int argc, char** argv)
1010

1111
//Modify instance.config here
1212

13+
// ffPrepareCPUUsage();
14+
// ffPreparePublicIp(&instance);
15+
// ffPrepareWeather(&instance);
16+
1317
//Does things like starting detection threads, disabling line wrap, etc
1418
ffStart(&instance);
1519

0 commit comments

Comments
 (0)