Skip to content
  • Mark Olesen's avatar
    use PackedBoolList typedef instead of PackedList<1> · 51fd6327
    Mark Olesen authored
    Note:
    
    PackedList constructor initializes to zero, faster not to do it
    ourselves.
    ie,
        PackedList foo(nPoints);
    vs.
        PackedList foo(nPoints, 0);
    
    saves an extra nPoints operations with shifts/masks etc.
    
    If speed is important, change this type of code
    
        PackedList isMaster(nPoints, 1u);
        for (loop)
        {
            if (condition)
            {
                isMaster.set(i, 0u);   // unset bit
            }
        }
        return isMaster;
    
    into this:
    
        PackedList notMaster(nPoints);
        for (loop)
        {
            if (!condition)
            {
                notMaster.set(i, 1u);
            }
        }
        notMaster.flip();
        return notMaster;
    
    or this:
    
        PackedList isMaster(nPoints);
        isMaster.flip();
    
        for (loop)
        {
            if (condition)
            {
                isMaster.set(i, 0u);
            }
        }
        return isMaster;
    51fd6327