mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
PackedBoolList specializaton for operator=
- now that I re-examined the code, the note in commit 51fd6327a6
can be mostly ignored
PackedList isMaster(nPoints, 1u);
is not really inefficient at all, since the '1u' is packed into
32/64-bits before the subsequent assignment and doesn't involve
shifts/masking for each index
The same misinformation applies to the PackedList(size, 0u) form.
It isn't much slower at all.
Nonetheless, add bool specialization so that it is a simple assign.
This commit is contained in:
@ -82,9 +82,13 @@ int main(int argc, char *argv[])
|
|||||||
argList::noParallel();
|
argList::noParallel();
|
||||||
argList::validArgs.insert("file .. fileN");
|
argList::validArgs.insert("file .. fileN");
|
||||||
|
|
||||||
argList::addBoolOption("mask");
|
argList::addBoolOption("mask", "report information about the bit masks");
|
||||||
argList::addBoolOption("count");
|
argList::addBoolOption("count", "test the count() method");
|
||||||
argList::addBoolOption("info");
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"info",
|
||||||
|
"print an ascii representation of the storage"
|
||||||
|
);
|
||||||
|
|
||||||
argList args(argc, argv, false, true);
|
argList args(argc, argv, false, true);
|
||||||
|
|
||||||
|
|||||||
@ -839,7 +839,24 @@ Foam::PackedList<nBits>::operator[](const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// specialization for nBits=1 isn't worth the bother
|
namespace Foam
|
||||||
|
{
|
||||||
|
// specialization for nBits=1
|
||||||
|
template<>
|
||||||
|
inline void Foam::PackedList<1>::operator=(const unsigned int val)
|
||||||
|
{
|
||||||
|
if (val)
|
||||||
|
{
|
||||||
|
StorageList::operator=(~0u);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StorageList::operator=(0u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<unsigned nBits>
|
template<unsigned nBits>
|
||||||
inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
inline void Foam::PackedList<nBits>::operator=(const unsigned int val)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user