@@ -431,9 +431,9 @@ std::list<std::pair<std::shared_ptr<std::string>,
431
431
432
432
std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars (
433
433
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;
437
437
std::vector<Variables::Variable *> variables;
438
438
std::vector<std::unique_ptr<collection::Variable>> finalVars;
439
439
@@ -448,8 +448,9 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
448
448
a.second ->evaluateInternal (trans, this , &z);
449
449
for (auto &y : z) {
450
450
exclusions_update_by_tag_remove.push_back (y->m_key );
451
+ delete y;
451
452
}
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 );
453
454
454
455
} else {
455
456
Variable *b = a.second .get ();
@@ -466,8 +467,9 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
466
467
a.second ->evaluateInternal (trans, this , &z);
467
468
for (auto &y : z) {
468
469
exclusions_update_by_id_remove.push_back (y->m_key );
470
+ delete y;
469
471
}
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 );
471
473
} else {
472
474
Variable *b = a.second .get ();
473
475
variables.push_back (b);
@@ -481,8 +483,9 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
481
483
variable->evaluateInternal (trans, this , &z);
482
484
for (auto &y : z) {
483
485
exclusions.push_back (y->m_key );
486
+ delete y;
484
487
}
485
- // exclusions.push_back(std::make_shared<std::string>(& variable->m_name) );
488
+ exclusions.push_back (variable->m_name );
486
489
}
487
490
}
488
491
@@ -497,73 +500,68 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
497
500
498
501
variable->evaluateInternal (trans, this , &e);
499
502
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
+
501
505
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 ; })
503
507
!= exclusions.end ()) {
504
508
#ifndef NO_LOGS
505
- trans->debug (9 , " Variable: " + * key +
509
+ trans->debug (9 , " Variable: " + key +
506
510
" is part of the exclusion list, skipping..." );
507
511
#endif
508
- if (v->m_dynamic ) {
509
512
delete v;
510
513
v = NULL ;
511
- }
512
514
continue ;
513
515
}
514
516
if (std::find_if (exclusions_update_by_tag_remove.begin (),
515
517
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 ; })
517
519
!= exclusions_update_by_tag_remove.end ()) {
518
520
#ifndef NO_LOGS
519
- trans->debug (9 , " Variable: " + * key +
521
+ trans->debug (9 , " Variable: " + key +
520
522
" is part of the exclusion list (from update by tag" +
521
523
" ), skipping..." );
522
524
#endif
523
- if (v->m_dynamic ) {
524
525
delete v;
525
526
v = NULL ;
526
- }
527
527
continue ;
528
528
}
529
529
530
530
if (std::find_if (exclusions_update_by_id_remove.begin (),
531
531
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 ; })
533
533
!= exclusions_update_by_id_remove.end ()) {
534
534
#ifndef NO_LOGS
535
- trans->debug (9 , " Variable: " + * key +
535
+ trans->debug (9 , " Variable: " + key +
536
536
" is part of the exclusion list (from update by ID), skipping..." );
537
537
#endif
538
- if (v->m_dynamic ) {
539
538
delete v;
540
539
v = NULL ;
541
- }
542
540
continue ;
543
541
}
544
542
545
543
for (auto &i : trans->m_ruleRemoveTargetByTag ) {
546
544
std::string tag = i.first ;
547
545
std::string args = i.second ;
548
- size_t posa = key-> find (" :" );
546
+ size_t posa = key. find (" :" );
549
547
550
548
if (containsTag (tag, trans) == false ) {
551
549
continue ;
552
550
}
553
551
554
- if (args == * key) {
552
+ if (args == key) {
555
553
#ifndef NO_LOGS
556
- trans->debug (9 , " Variable: " + * key +
554
+ trans->debug (9 , " Variable: " + key +
557
555
" was excluded by ruleRemoteTargetByTag..." );
558
556
#endif
559
557
ignoreVariable = true ;
560
558
break ;
561
559
}
562
560
if (posa != std::string::npos) {
563
- std::string var = std::string (* key, posa);
561
+ std::string var = std::string (key, posa);
564
562
if (var == args) {
565
563
#ifndef NO_LOGS
566
- trans->debug (9 , " Variable: " + * key +
564
+ trans->debug (9 , " Variable: " + key +
567
565
" was excluded by ruleRemoteTargetByTag..." );
568
566
#endif
569
567
ignoreVariable = true ;
@@ -572,33 +570,31 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
572
570
}
573
571
}
574
572
if (ignoreVariable) {
575
- if (v->m_dynamic ) {
576
573
delete v;
577
574
v = NULL ;
578
- }
579
575
continue ;
580
576
}
581
577
582
578
for (auto &i : trans->m_ruleRemoveTargetById ) {
583
579
int id = i.first ;
584
580
std::string args = i.second ;
585
- size_t posa = key-> find (" :" );
581
+ size_t posa = key. find (" :" );
586
582
587
583
if (m_ruleId != id) {
588
584
continue ;
589
585
}
590
586
591
- if (args == * key) {
587
+ if (args == key) {
592
588
#ifndef NO_LOGS
593
- trans->debug (9 , " Variable: " + * key +
589
+ trans->debug (9 , " Variable: " + key +
594
590
" was excluded by ruleRemoveTargetById..." );
595
591
#endif
596
592
ignoreVariable = true ;
597
593
break ;
598
594
}
599
595
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);
602
598
if (var == args) {
603
599
#ifndef NO_LOGS
604
600
trans->debug (9 , " Variable: " + var +
@@ -611,27 +607,14 @@ std::vector<std::unique_ptr<collection::Variable>> Rule::getFinalVars(
611
607
}
612
608
}
613
609
if (ignoreVariable) {
614
- if (v->m_dynamic ) {
615
610
delete v;
616
611
v = NULL ;
617
- }
618
612
continue ;
619
613
}
620
614
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 ;
635
618
finalVars.push_back (std::move (var));
636
619
}
637
620
}
@@ -772,8 +755,8 @@ bool Rule::evaluate(Transaction *trans,
772
755
finalVars = getFinalVars (trans);
773
756
774
757
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 ;
777
760
778
761
std::list<std::pair<std::shared_ptr<std::string>,
779
762
std::shared_ptr<std::string>>> values;
0 commit comments