mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user