@@ -258,17 +258,15 @@ StatusOr<double> CandidateMerge::ComputeCostDelta(
258258 modified_conditions));
259259
260260 double cost_delta = 0.0 ;
261- VLOG (1 ) << " cost delta for merge of " << merged_segments.ToString () << " :" ;
261+ VLOG (1 ) << " cost_delta for merge of " << merged_segments.ToString ()
262+ << " =" ;
262263 if (!moving_to_init_font) {
263264 // Merge will introduce a new patch (merged_segment) with size
264265 // "new_patch_size", add the associated cost.
265266 double p = (*merged_segment)->Probability ();
266- cost_delta += p * (new_patch_size + per_request_overhead);
267- VLOG (1 ) << " cost_delta for merge of " << merged_segments.ToString ()
268- << " =" ;
269-
270- VLOG (1 ) << " + (" << p << " * "
271- << (new_patch_size + per_request_overhead) << " ) -> " << cost_delta
267+ double s = new_patch_size + per_request_overhead;
268+ cost_delta += p * s;
269+ VLOG (1 ) << " + (" << p << " * " << s << " ) -> " << cost_delta
272270 << " [merged patch]" ;
273271 } else {
274272 // Otherwise the merged segments are being moved to the init font, compute
@@ -316,6 +314,10 @@ StatusOr<double> CandidateMerge::ComputeCostDelta(
316314 // the cost addition as usual.
317315 SegmentSet condition_segments = c.TriggeringSegments ();
318316 condition_segments.subtract (merged_segments);
317+ if (condition_segments.empty ()) {
318+ continue ;
319+ }
320+
319321 ActivationCondition new_condition =
320322 ActivationCondition::and_segments (condition_segments, 0 );
321323 double p = TRY (c.Probability (
0 commit comments