summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-22 15:34:53 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2017-12-22 15:36:31 +0100
commitefb419fd7408f4c570804a40071c8236f6eb5193 (patch)
tree2eb6c8be4c8903b3599bebd7985c51db47f73176
parent65ea735fd7d32aeeffb2380aa9442a010d6d439e (diff)
eolian: prevent unnecessary hash table allocs
-rw-r--r--src/lib/eolian/database_validate.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/lib/eolian/database_validate.c b/src/lib/eolian/database_validate.c
index 9fd9e59379..9ac74dba76 100644
--- a/src/lib/eolian/database_validate.c
+++ b/src/lib/eolian/database_validate.c
@@ -447,17 +447,12 @@ _validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
447 Eolian_Part *part; 447 Eolian_Part *part;
448 Eolian_Implement *impl; 448 Eolian_Implement *impl;
449 Eolian_Class *icl; 449 Eolian_Class *icl;
450 Eina_Bool res = EINA_TRUE;
451 450
452 if (!cl) 451 if (!cl)
453 return EINA_FALSE; /* if this happens something is very wrong though */ 452 return EINA_FALSE; /* if this happens something is very wrong though */
454 453
455 Eina_Bool valid = cl->base.validated; 454 Eina_Bool valid = cl->base.validated;
456 455
457 Eina_Bool ahash = (nhash == NULL);
458 if (ahash)
459 nhash = eina_hash_string_small_new(NULL);
460
461 EINA_LIST_FOREACH(cl->inherits, l, icl) 456 EINA_LIST_FOREACH(cl->inherits, l, icl)
462 { 457 {
463 /* first inherit needs some checking done on it */ 458 /* first inherit needs some checking done on it */
@@ -486,42 +481,37 @@ _validate_class(const Eolian_Unit *src, Eolian_Class *cl, Eina_Hash *nhash)
486 default: 481 default:
487 break; 482 break;
488 } 483 }
489 if (!(res = _validate_class(src, icl, nhash))) 484 if (!_validate_class(src, icl, nhash))
490 goto freehash; 485 return EINA_FALSE;
491 } 486 }
492 487
493 EINA_LIST_FOREACH(cl->properties, l, func) 488 EINA_LIST_FOREACH(cl->properties, l, func)
494 if (!(res = _validate_function(src, func, nhash))) 489 if (!_validate_function(src, func, nhash))
495 goto freehash; 490 return EINA_FALSE;
496 491
497 EINA_LIST_FOREACH(cl->methods, l, func) 492 EINA_LIST_FOREACH(cl->methods, l, func)
498 if (!(res = _validate_function(src, func, nhash))) 493 if (!_validate_function(src, func, nhash))
499 goto freehash; 494 return EINA_FALSE;
500 495
501 EINA_LIST_FOREACH(cl->events, l, event) 496 EINA_LIST_FOREACH(cl->events, l, event)
502 if (!(res = _validate_event(src, event))) 497 if (!_validate_event(src, event))
503 goto freehash; 498 return EINA_FALSE;
504 499
505 EINA_LIST_FOREACH(cl->parts, l, part) 500 EINA_LIST_FOREACH(cl->parts, l, part)
506 if (!(res = _validate_part(src, part, nhash))) 501 if (!_validate_part(src, part, nhash))
507 goto freehash; 502 return EINA_FALSE;
508 503
509 EINA_LIST_FOREACH(cl->implements, l, impl) 504 EINA_LIST_FOREACH(cl->implements, l, impl)
510 if (!(res = _validate_implement(src, impl))) 505 if (!_validate_implement(src, impl))
511 goto freehash; 506 return EINA_FALSE;
512 507
513 /* all the checks that need to be done every time are performed now */ 508 /* all the checks that need to be done every time are performed now */
514 if (valid) 509 if (valid)
515 goto freehash; 510 return EINA_TRUE;
516
517 if (!(res = _validate_doc(src, cl->doc)))
518 goto freehash;
519 511
520freehash: 512 if (!_validate_doc(src, cl->doc))
521 if (ahash)
522 eina_hash_free(nhash);
523 if (!res)
524 return EINA_FALSE; 513 return EINA_FALSE;
514
525 return _validate(&cl->base); 515 return _validate(&cl->base);
526} 516}
527 517
@@ -563,12 +553,18 @@ database_validate(Eolian *state, const Eolian_Unit *src)
563 Eolian_Class *cl; 553 Eolian_Class *cl;
564 554
565 Eina_Iterator *iter = eolian_all_classes_get(src); 555 Eina_Iterator *iter = eolian_all_classes_get(src);
556 Eina_Hash *nhash = eina_hash_string_small_new(NULL);
566 EINA_ITERATOR_FOREACH(iter, cl) 557 EINA_ITERATOR_FOREACH(iter, cl)
567 if (!_validate_class(src, cl, NULL)) 558 {
568 { 559 eina_hash_free_buckets(nhash);
569 eina_iterator_free(iter); 560 if (!_validate_class(src, cl, nhash))
570 return EINA_FALSE; 561 {
571 } 562 eina_iterator_free(iter);
563 eina_hash_free(nhash);
564 return EINA_FALSE;
565 }
566 }
567 eina_hash_free(nhash);
572 eina_iterator_free(iter); 568 eina_iterator_free(iter);
573 569
574 Cb_Ret rt = { src, EINA_TRUE }; 570 Cb_Ret rt = { src, EINA_TRUE };