Skip to content

Commit 152445c

Browse files
committed
More speed via static_cast
1 parent 7b58aa3 commit 152445c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/solvertypesmini.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -524,43 +524,43 @@ class FDouble : public Field {
524524
FDouble(const FDouble& other) : val(other.val) {}
525525

526526
Field& operator=(const Field& other) override {
527-
const auto& od = dynamic_cast<const FDouble&>(other);
527+
const auto& od = static_cast<const FDouble&>(other);
528528
val = od.val;
529529
return *this;
530530
}
531531

532532
Field& operator+=(const Field& other) override {
533-
const auto& od = dynamic_cast<const FDouble&>(other);
533+
const auto& od = static_cast<const FDouble&>(other);
534534
val += od.val;
535535
return *this;
536536
}
537537

538538
std::unique_ptr<Field> add(const Field& other) override {
539-
const auto& od = dynamic_cast<const FDouble&>(other);
539+
const auto& od = static_cast<const FDouble&>(other);
540540
return std::make_unique<FDouble>(val + od.val);
541541
}
542542

543543
Field& operator-=(const Field& other) override {
544-
const auto& od = dynamic_cast<const FDouble&>(other);
544+
const auto& od = static_cast<const FDouble&>(other);
545545
val -= od.val;
546546
return *this;
547547
}
548548

549549
Field& operator*=(const Field& other) override {
550-
const auto& od = dynamic_cast<const FDouble&>(other);
550+
const auto& od = static_cast<const FDouble&>(other);
551551
val *= od.val;
552552
return *this;
553553
}
554554

555555
Field& operator/=(const Field& other) override {
556-
const auto& od = dynamic_cast<const FDouble&>(other);
556+
const auto& od = static_cast<const FDouble&>(other);
557557
if (od.val == 0) throw std::runtime_error("Division by zero");
558558
val /= od.val;
559559
return *this;
560560
}
561561

562562
bool operator==(const Field& other) const override {
563-
const auto& od = dynamic_cast<const FDouble&>(other);
563+
const auto& od = static_cast<const FDouble&>(other);
564564
return od.val == val;
565565
}
566566

@@ -621,8 +621,8 @@ class FGenDouble : public FieldGen {
621621
}
622622

623623
bool larger_than(const Field& a, const Field& b) const override {
624-
const auto& ad = dynamic_cast<const FDouble&>(a);
625-
const auto& bd = dynamic_cast<const FDouble&>(b);
624+
const auto& ad = static_cast<const FDouble&>(a);
625+
const auto& bd = static_cast<const FDouble&>(b);
626626
return ad.val > bd.val;
627627
}
628628

@@ -637,43 +637,43 @@ class FMpz : public Field {
637637
FMpz(const FMpz& other) : val(other.val) {}
638638

639639
Field& operator=(const Field& other) override {
640-
const auto& od = dynamic_cast<const FMpz&>(other);
640+
const auto& od = static_cast<const FMpz&>(other);
641641
val = od.val;
642642
return *this;
643643
}
644644

645645
Field& operator+=(const Field& other) override {
646-
const auto& od = dynamic_cast<const FMpz&>(other);
646+
const auto& od = static_cast<const FMpz&>(other);
647647
val += od.val;
648648
return *this;
649649
}
650650

651651
std::unique_ptr<Field> add(const Field& other) override {
652-
const auto& od = dynamic_cast<const FMpz&>(other);
652+
const auto& od = static_cast<const FMpz&>(other);
653653
return std::make_unique<FMpz>(val + od.val);
654654
}
655655

656656
Field& operator-=(const Field& other) override {
657-
const auto& od = dynamic_cast<const FMpz&>(other);
657+
const auto& od = static_cast<const FMpz&>(other);
658658
val -= od.val;
659659
return *this;
660660
}
661661

662662
Field& operator*=(const Field& other) override {
663-
const auto& od = dynamic_cast<const FMpz&>(other);
663+
const auto& od = static_cast<const FMpz&>(other);
664664
val *= od.val;
665665
return *this;
666666
}
667667

668668
Field& operator/=(const Field& other) override {
669-
const auto& od = dynamic_cast<const FMpz&>(other);
669+
const auto& od = static_cast<const FMpz&>(other);
670670
if (od.val == 0) throw std::runtime_error("Division by zero");
671671
val /= od.val;
672672
return *this;
673673
}
674674

675675
bool operator==(const Field& other) const override {
676-
const auto& od = dynamic_cast<const FMpz&>(other);
676+
const auto& od = static_cast<const FMpz&>(other);
677677
return od.val == val;
678678
}
679679

@@ -722,8 +722,8 @@ class FGenMpz : public FieldGen {
722722
}
723723

724724
bool larger_than(const Field& a, const Field& b) const override {
725-
const auto& ad = dynamic_cast<const FMpz&>(a);
726-
const auto& bd = dynamic_cast<const FMpz&>(b);
725+
const auto& ad = static_cast<const FMpz&>(a);
726+
const auto& bd = static_cast<const FMpz&>(b);
727727
return ad.val > bd.val;
728728
}
729729

0 commit comments

Comments
 (0)