@@ -431,9 +431,9 @@ std::list<std::pair<std::shared_ptr<std::string>,
431431
432432std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars (
433433 Transaction *trans) {
434- std::list<std::shared_ptr<std:: string> > exclusions;
435- std::list<std::shared_ptr<std:: string> > exclusions_update_by_tag_remove;
436- std::list<std::shared_ptr<std:: string> > exclusions_update_by_id_remove;
434+ std::list<std::string> exclusions;
435+ std::list<std::string> exclusions_update_by_tag_remove;
436+ std::list<std::string> exclusions_update_by_id_remove;
437437 std::vector<Variables::Variable *> variables;
438438 std::vector<std::unique_ptr<collection::Variable>> finalVars;
439439
@@ -448,8 +448,9 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
448448 a.second ->evaluateInternal (trans, this , &z);
449449 for (auto &y : z) {
450450 exclusions_update_by_tag_remove.push_back (y->m_key );
451+ delete y;
451452 }
452- exclusions_update_by_tag_remove.push_back (std::make_shared<std::string>( a.second ->m_name ) );
453+ exclusions_update_by_tag_remove.push_back (a.second ->m_name );
453454
454455 } else {
455456 Variable *b = a.second .get ();
@@ -466,8 +467,9 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
466467 a.second ->evaluateInternal (trans, this , &z);
467468 for (auto &y : z) {
468469 exclusions_update_by_id_remove.push_back (y->m_key );
470+ delete y;
469471 }
470- exclusions_update_by_id_remove.push_back (std::make_shared<std::string>( a.second ->m_name ) );
472+ exclusions_update_by_id_remove.push_back (a.second ->m_name );
471473 } else {
472474 Variable *b = a.second .get ();
473475 variables.push_back (b);
@@ -481,8 +483,9 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
481483 variable->evaluateInternal (trans, this , &z);
482484 for (auto &y : z) {
483485 exclusions.push_back (y->m_key );
486+ delete y;
484487 }
485- // exclusions.push_back(std::make_shared<std::string>(& variable->m_name) );
488+ exclusions.push_back (variable->m_name );
486489 }
487490 }
488491
@@ -497,73 +500,68 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
497500
498501 variable->evaluateInternal (trans, this , &e);
499502 for (const collection::Variable *v : e) {
500- const std::shared_ptr<std::string> key = v->m_key ;
503+ std::string key = v->m_key ;
504+
501505 if (std::find_if (exclusions.begin (), exclusions.end (),
502- [key](std::shared_ptr<std:: string> m) -> bool { return * key == *m. get () ; })
506+ [key](std::string m) -> bool { return key == m ; })
503507 != exclusions.end ()) {
504508#ifndef NO_LOGS
505- trans->debug (9 , " Variable: " + * key +
509+ trans->debug (9 , " Variable: " + key +
506510 " is part of the exclusion list, skipping..." );
507511#endif
508- if (v->m_dynamic ) {
509512 delete v;
510513 v = NULL ;
511- }
512514 continue ;
513515 }
514516 if (std::find_if (exclusions_update_by_tag_remove.begin (),
515517 exclusions_update_by_tag_remove.end (),
516- [key](std::shared_ptr<std:: string> m) -> bool { return * key == *m. get () ; })
518+ [key](std::string m) -> bool { return key == m ; })
517519 != exclusions_update_by_tag_remove.end ()) {
518520#ifndef NO_LOGS
519- trans->debug (9 , " Variable: " + * key +
521+ trans->debug (9 , " Variable: " + key +
520522 " is part of the exclusion list (from update by tag" +
521523 " ), skipping..." );
522524#endif
523- if (v->m_dynamic ) {
524525 delete v;
525526 v = NULL ;
526- }
527527 continue ;
528528 }
529529
530530 if (std::find_if (exclusions_update_by_id_remove.begin (),
531531 exclusions_update_by_id_remove.end (),
532- [key](std::shared_ptr<std:: string> m) -> bool { return * key == *m. get () ; })
532+ [key](std::string m) -> bool { return key == m ; })
533533 != exclusions_update_by_id_remove.end ()) {
534534#ifndef NO_LOGS
535- trans->debug (9 , " Variable: " + * key +
535+ trans->debug (9 , " Variable: " + key +
536536 " is part of the exclusion list (from update by ID), skipping..." );
537537#endif
538- if (v->m_dynamic ) {
539538 delete v;
540539 v = NULL ;
541- }
542540 continue ;
543541 }
544542
545543 for (auto &i : trans->m_ruleRemoveTargetByTag ) {
546544 std::string tag = i.first ;
547545 std::string args = i.second ;
548- size_t posa = key-> find (" :" );
546+ size_t posa = key. find (" :" );
549547
550548 if (containsTag (tag, trans) == false ) {
551549 continue ;
552550 }
553551
554- if (args == * key) {
552+ if (args == key) {
555553#ifndef NO_LOGS
556- trans->debug (9 , " Variable: " + * key +
554+ trans->debug (9 , " Variable: " + key +
557555 " was excluded by ruleRemoteTargetByTag..." );
558556#endif
559557 ignoreVariable = true ;
560558 break ;
561559 }
562560 if (posa != std::string::npos) {
563- std::string var = std::string (* key, posa);
561+ std::string var = std::string (key, posa);
564562 if (var == args) {
565563#ifndef NO_LOGS
566- trans->debug (9 , " Variable: " + * key +
564+ trans->debug (9 , " Variable: " + key +
567565 " was excluded by ruleRemoteTargetByTag..." );
568566#endif
569567 ignoreVariable = true ;
@@ -572,33 +570,31 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
572570 }
573571 }
574572 if (ignoreVariable) {
575- if (v->m_dynamic ) {
576573 delete v;
577574 v = NULL ;
578- }
579575 continue ;
580576 }
581577
582578 for (auto &i : trans->m_ruleRemoveTargetById ) {
583579 int id = i.first ;
584580 std::string args = i.second ;
585- size_t posa = key-> find (" :" );
581+ size_t posa = key. find (" :" );
586582
587583 if (m_ruleId != id) {
588584 continue ;
589585 }
590586
591- if (args == * key) {
587+ if (args == key) {
592588#ifndef NO_LOGS
593- trans->debug (9 , " Variable: " + * key +
589+ trans->debug (9 , " Variable: " + key +
594590 " was excluded by ruleRemoveTargetById..." );
595591#endif
596592 ignoreVariable = true ;
597593 break ;
598594 }
599595 if (posa != std::string::npos) {
600- if (key-> size () > posa) {
601- std::string var = std::string (* key, 0 , posa);
596+ if (key. size () > posa) {
597+ std::string var = std::string (key, 0 , posa);
602598 if (var == args) {
603599#ifndef NO_LOGS
604600 trans->debug (9 , " Variable: " + var +
@@ -611,27 +607,14 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
611607 }
612608 }
613609 if (ignoreVariable) {
614- if (v->m_dynamic ) {
615610 delete v;
616611 v = NULL ;
617- }
618612 continue ;
619613 }
620614
621- std::unique_ptr<collection::Variable> var (new collection::Variable (
622- new std::string (*v->m_key ),
623- new std::string (*v->m_value )));
624- for (auto &i : v->m_orign ) {
625- std::unique_ptr<VariableOrigin> origin (new VariableOrigin ());
626- origin->m_offset = i->m_offset ;
627- origin->m_length = i->m_length ;
628- var->m_orign .push_back (std::move (origin));
629- }
630-
631- if (v->m_dynamic ) {
632- delete v;
633- v = NULL ;
634- }
615+ std::unique_ptr<collection::Variable> var (new collection::Variable (v));
616+ delete v;
617+ v = NULL ;
635618 finalVars.push_back (std::move (var));
636619 }
637620 }
@@ -772,8 +755,8 @@ bool Rule::evaluate(Transaction *trans,
772755 finalVars = getFinalVars (trans);
773756
774757 for (auto &v : finalVars) {
775- const std::string value = *( v->m_value ) ;
776- const std::string key = *( v->m_key ) ;
758+ const std::string value = v->m_value ;
759+ const std::string key = v->m_key ;
777760
778761 std::list<std::pair<std::shared_ptr<std::string>,
779762 std::shared_ptr<std::string>>> values;
0 commit comments