summaryrefslogtreecommitdiff
path: root/src/lib/evas/file
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-08-08 23:55:40 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-08-08 23:57:02 +0100
commit9149767184bfa9b64102eaea89f6733351de71e9 (patch)
tree1f2bdb7527a00f9ae3c8dd21fbf5a88cd305dfe4 /src/lib/evas/file
parentcdb920ab084451c8395dea605d96d2bad277ce61 (diff)
getenv - reduce continually calling getenv for the same vars do once
do it once and remember the result from the first one. drops overhead for sure by a chunk i actually could see in perf reports like about 1-2% of cpu...
Diffstat (limited to 'src/lib/evas/file')
-rw-r--r--src/lib/evas/file/evas_module.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/lib/evas/file/evas_module.c b/src/lib/evas/file/evas_module.c
index b467ebcdbf..a1e8b623af 100644
--- a/src/lib/evas/file/evas_module.c
+++ b/src/lib/evas/file/evas_module.c
@@ -116,7 +116,14 @@ evas_module_paths_init(void)
116 if (getuid() == geteuid()) 116 if (getuid() == geteuid())
117#endif 117#endif
118 { 118 {
119 if (getenv("EFL_RUN_IN_TREE")) 119 static signed char run_in_tree = -1;
120
121 if (run_in_tree == -1)
122 {
123 if (getenv("EFL_RUN_IN_TREE")) run_in_tree = 1;
124 else run_in_tree = 0;
125 }
126 if (run_in_tree == 1)
120 { 127 {
121 struct stat st; 128 struct stat st;
122 const char mp[] = PACKAGE_BUILD_DIR"/src/modules/evas"; 129 const char mp[] = PACKAGE_BUILD_DIR"/src/modules/evas";
@@ -432,9 +439,13 @@ evas_module_engine_list(void)
432 const char *s, *s2; 439 const char *s, *s2;
433 char buf[PATH_MAX]; 440 char buf[PATH_MAX];
434#ifdef NEED_RUN_IN_TREE 441#ifdef NEED_RUN_IN_TREE
435 Eina_Bool run_in_tree; 442 static signed char run_in_tree = -1;
436 443
437 run_in_tree = !!getenv("EFL_RUN_IN_TREE"); 444 if (run_in_tree == -1)
445 {
446 if (getenv("EFL_RUN_IN_TREE")) run_in_tree = 1;
447 else run_in_tree = 0;
448 }
438#endif 449#endif
439 450
440 EINA_LIST_FOREACH(evas_module_paths, l, s) 451 EINA_LIST_FOREACH(evas_module_paths, l, s)
@@ -455,7 +466,7 @@ evas_module_engine_list(void)
455 if (getuid() == geteuid()) 466 if (getuid() == geteuid())
456#endif 467#endif
457 { 468 {
458 if (run_in_tree) 469 if (run_in_tree == 1)
459 { 470 {
460 bs_mod_dir_get(buf, sizeof(buf), "evas/engines", fname); 471 bs_mod_dir_get(buf, sizeof(buf), "evas/engines", fname);
461 if (!evas_file_path_exists(buf)) 472 if (!evas_file_path_exists(buf))
@@ -549,7 +560,13 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
549 Eina_Module *en; 560 Eina_Module *en;
550 Eina_List *l; 561 Eina_List *l;
551#ifdef NEED_RUN_IN_TREE 562#ifdef NEED_RUN_IN_TREE
552 Eina_Bool run_in_tree; 563 static signed char run_in_tree = -1;
564
565 if (run_in_tree == -1)
566 {
567 if (getenv("EFL_RUN_IN_TREE")) run_in_tree = 1;
568 else run_in_tree = 0;
569 }
553#endif 570#endif
554 571
555 if ((unsigned int)type > 5) return NULL; 572 if ((unsigned int)type > 5) return NULL;
@@ -561,10 +578,6 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
561 return NULL; 578 return NULL;
562 } 579 }
563 580
564#ifdef NEED_RUN_IN_TREE
565 run_in_tree = !!getenv("EFL_RUN_IN_TREE");
566#endif
567
568 EINA_LIST_FOREACH(evas_module_paths, l, path) 581 EINA_LIST_FOREACH(evas_module_paths, l, path)
569 { 582 {
570 const char *type_str = "unknown"; 583 const char *type_str = "unknown";
@@ -584,7 +597,7 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
584 if (getuid() == geteuid()) 597 if (getuid() == geteuid())
585#endif 598#endif
586 { 599 {
587 if (run_in_tree) 600 if (run_in_tree == 1)
588 { 601 {
589 char subsystem[PATH_MAX]; 602 char subsystem[PATH_MAX];
590 603
@@ -700,7 +713,7 @@ evas_module_clean(void)
700{ 713{
701 static int call_count = 0; 714 static int call_count = 0;
702/* int ago; */ 715/* int ago; */
703 int noclean = -1; 716 static signed char noclean = -1;
704/* Eina_List *l; */ 717/* Eina_List *l; */
705/* Evas_Module *em; */ 718/* Evas_Module *em; */
706 719
@@ -711,10 +724,8 @@ evas_module_clean(void)
711 724
712 if (noclean == -1) 725 if (noclean == -1)
713 { 726 {
714 if (getenv("EVAS_NOCLEAN")) 727 if (getenv("EVAS_NOCLEAN")) noclean = 1;
715 noclean = 1; 728 else noclean = 0;
716 else
717 noclean = 0;
718 } 729 }
719 if (noclean == 1) return; 730 if (noclean == 1) return;
720 731