Skip to content

Commit 821154a

Browse files
committed
Couple small cleanups.
1 parent 38337fc commit 821154a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

ift/encoder/candidate_merge.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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(

ift/encoder/closure_glyph_segmenter.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,9 @@ Status ClosureGlyphSegmenter::MoveSegmentsToInitFont(
664664
do {
665665
// TODO(garretrieger): as an optimization probably want to avoid rechecking
666666
// segments that have previously been assessed for move into init font.
667+
// alternatively should be able to modify this to not immediately apply
668+
// the move, but scan all options and collect the set of segments to move
669+
// then repeat analysis until no changes.
667670
// TODO(garretrieger): consider reworking this using gids instead of
668671
// codepoints. That is specify init font def in terms of gids. That will
669672
// more closely match the intention of merging a specific patch into the

0 commit comments

Comments
 (0)