Skip to content

Commit c919203

Browse files
committed
invert boolean to reduce nesting
1 parent 0113088 commit c919203

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/boilerpipe/filters/block_proximity_fusion.rb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@ def process(doc)
3333
end
3434

3535
diff_blocks = tb.offset_blocks_start - prev_block.offset_blocks_end - 1
36-
if diff_blocks <= @max_blocks_distance
37-
ok = true
38-
ok = false if prev_block.is_not_content? && @content_only
39-
ok = false if ok && prev_block.tag_level != tb.tag_level && @same_tag_level_only
40-
41-
if ok
42-
prev_block.merge_next(tb)
43-
blocks_to_remove << tb
44-
else
45-
prev_block = tb
46-
end
36+
next if diff_blocks > @max_blocks_distance
37+
38+
ok = true
39+
ok = false if prev_block.is_not_content? && @content_only
40+
ok = false if ok && prev_block.tag_level != tb.tag_level && @same_tag_level_only
41+
42+
if ok
43+
prev_block.merge_next(tb)
44+
blocks_to_remove << tb
45+
else
46+
prev_block = tb
4747
end
4848
end
49+
4950
doc.replace_text_blocks!(text_blocks - blocks_to_remove)
5051
doc
5152
end

0 commit comments

Comments
 (0)