This is an archive of the discontinued LLVM Phabricator instance.

[ADT][NFC] Early bail out for ComputeEditDistance
ClosedPublic

Authored by njames93 on Jun 5 2022, 4:20 AM.

Details

Summary

The minimun bound for number of edits is the size difference between the 2 arrays.
If MaxEditDistance is smaller than this, we can bail out early without needing to traverse any of the arrays.

Diff Detail

Event Timeline

njames93 created this revision.Jun 5 2022, 4:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2022, 4:20 AM
njames93 requested review of this revision.Jun 5 2022, 4:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2022, 4:20 AM
dblaikie accepted this revision.Jun 5 2022, 12:20 PM

Could be unit tested with a counting map functor? Though I'm not sure that's strictly necessary/worthwhile, up to you.

This revision is now accepted and ready to land.Jun 5 2022, 12:20 PM
njames93 updated this revision to Diff 434755.Jun 7 2022, 3:12 AM

Add tests to verify bailing out.

dblaikie accepted this revision.Jun 7 2022, 11:35 AM

Looks good, thanks!

llvm/unittests/ADT/EditDistanceTest.cpp
36–37

Generally prefer implicit construction over explicit where they're both valid - since implicit is strictly less powerful.

This revision was landed with ongoing or failed builds.Jun 8 2022, 12:20 AM
This revision was automatically updated to reflect the committed changes.