@@ -485,13 +485,11 @@ std::shared_ptr<MatchConstraint> DecimalsHaveSameScale() {
485485 DCHECK_GE (types.size (), 2 );
486486 DCHECK (std::all_of (types.begin (), types.end (),
487487 [](const TypeHolder& type) { return is_decimal (type.id ()); }));
488- auto ty0 = checked_cast<const DecimalType*>(types[0 ].type );
489- DCHECK_NE (ty0, nullptr );
490- auto s0 = ty0->scale ();
488+ const auto & ty0 = checked_cast<const DecimalType&>(*types[0 ].type );
489+ auto s0 = ty0.scale ();
491490 for (size_t i = 1 ; i < types.size (); ++i) {
492- auto ty = checked_cast<const DecimalType*>(types[i].type );
493- DCHECK_NE (ty, nullptr );
494- if (ty->scale () != s0) {
491+ const auto & ty = checked_cast<const DecimalType&>(*types[i].type );
492+ if (ty.scale () != s0) {
495493 return false ;
496494 }
497495 }
@@ -511,11 +509,9 @@ class BinaryDecimalScaleComparisonConstraint : public MatchConstraint {
511509 DCHECK_EQ (types.size (), 2 );
512510 DCHECK (is_decimal (types[0 ].id ()));
513511 DCHECK (is_decimal (types[1 ].id ()));
514- auto ty0 = checked_cast<const DecimalType*>(types[0 ].type );
515- DCHECK_NE (ty0, nullptr );
516- auto ty1 = checked_cast<const DecimalType*>(types[1 ].type );
517- DCHECK_NE (ty1, nullptr );
518- return Op{}(ty0->scale (), ty1->scale ());
512+ const auto & ty0 = checked_cast<const DecimalType&>(*types[0 ].type );
513+ const auto & ty1 = checked_cast<const DecimalType&>(*types[1 ].type );
514+ return Op{}(ty0.scale (), ty1.scale ());
519515 }
520516};
521517
@@ -580,9 +576,9 @@ bool KernelSignature::MatchesInputs(const std::vector<TypeHolder>& types) const
580576 return false ;
581577 }
582578 }
583- if (constraint_ && !constraint_-> Matches (types)) {
584- return false ;
585- }
579+ }
580+ if (constraint_ && !constraint_-> Matches (types)) {
581+ return false ;
586582 }
587583 return true ;
588584}
0 commit comments