-
Notifications
You must be signed in to change notification settings - Fork 79
Closed
Labels
Description
Understanding this method is important for understanding the whole algorithm and I'm not fond of adding two boolean arguments to it. It's hard to follow what they mean when the method is called. In fact, I think I largely preferred the old code which used an explicit * to represent ranges.
A few suggestions on how to improve this code. I'm not saying all of them need to be applied at the same time, but I'd like to see this method improved somehow.
- Remove the
thisRangeparam as it is alwaystrueacross all callsites, or start using it for exact matching. - Use an
optionsdictionary:locale.matches(other, {thisRange: true, otherRange: true}). - Separate this code into multiple methods:
exactMatches,matchesThisRange,matchesRanges. - Add a flag to
LocalecalledundefinedAsRangeand a method calledtoRange()which returns a newLocaleinstance based on the one the method was called on.matchwould inspect the value of the flag for boththisandotherand act accordingly.
Now, I understand that this code is based on the existing C++/Rust code. With that in mind, I think this can be moved to a follow-up. Please file it if you agree.
Reactions are currently unavailable