ENH: prevent conversion of string to regExp in stringListOps (closes #739)

* For most cases, this conversion would be largely unintentional
  and also less efficient. If the regex is desirable, the caller
  should invoke it explicitly.
  For example,

      findStrings(regExp(str), listOfStrings);

  Or use one of the keyType, wordRe, wordRes variants instead.
  If string is to be used as a plain (non-regex) matcher,
  this can be directly invoked

      findMatchingStrings(str, listOfStrings);

  or using the ListOps instead:

      findIndices(listOfStrings, str);

* provide function interfaces for keyType.
This commit is contained in:
Mark Olesen
2018-02-22 09:28:03 +01:00
parent f959927910
commit ec38e7a408
16 changed files with 264 additions and 226 deletions

View File

@ -178,7 +178,6 @@ bool addEntry
}
// List of indices into thisKeys
labelList findMatches
(
@ -194,19 +193,19 @@ labelList findMatches
{
// Wildcard match
matches = findStrings(key, thisKeys);
}
else if (shortcuts.size())
{
// See if patchGroups expand to valid thisKeys
labelList indices = findStrings(key, shortcutNames);
forAll(indices, i)
for (const label idx : indices)
{
const word& name = shortcutNames[indices[i]];
const word& name = shortcutNames[idx];
const wordList& keys = shortcuts[name];
forAll(keys, j)
{
label index = thisKeys.find(keys[j]);
const label index = thisKeys.find(keys[j]);
if (index != -1)
{
matches.append(index);