// constructs a mask that selects bits <from> to <to> inclusive of a UInt staticinline UInt MaskForCopyBits(UInt from, UInt to)
{ return ((to == BIPEB - 1) ? 0 : ((UInt)1 << (to + 1))) - ((UInt)1 << from);
}
/* copies a block of bits from the UInt <from> to the one pointed at by<to>theblockstartsin<from>at<startbit>andendsat <endbit>.Itisshiftedleftby<shift>andmuststillfitwithina singleword(soendbits+shiftmustbe<BIPEBandfrombits+
shift must be non-negative */
static ALWAYS_INLINE void CopyBits(const UInt * fromblock,
UInt frombit,
UInt * toblock,
UInt tobit,
UInt nbits)
{
UInt tailbits;
UInt x;
UInt wholeblocks; if (!nbits) return;
GAP_ASSERT(frombit < BIPEB);
GAP_ASSERT(tobit < BIPEB); /* If the alignment of the two data blocks matches, things are relatively *easy
*/ if (frombit == tobit) { // if the first and last words are the same word if ((frombit + nbits) < BIPEB) {
CopyInWord(toblock, frombit, frombit + nbits - 1, *fromblock, 0); return;
} // do we need to start by copying a partial word if (frombit) {
CopyInWord(toblock, frombit, BIPEB - 1, *fromblock, 0);
fromblock++;
toblock++;
nbits -= (BIPEB - frombit);
} // Now move whole words if ((wholeblocks = nbits / BIPEB))
memcpy(toblock, fromblock, sizeof(UInt) * wholeblocks);
toblock += wholeblocks;
fromblock += wholeblocks;
nbits %= BIPEB; // Finally, we may need to finish with another partial word if (nbits)
CopyInWord(toblock, 0, nbits - 1, *fromblock, 0); return;
}
// Otherwise the bits are not aligned and we will be shifting
if (tobit) { /* How many bits are we going to put into the first destination word
*/ if (tobit + nbits <= BIPEB)
tailbits = nbits; else
tailbits = BIPEB - tobit; // We might be able to get all we need from the first source word if (frombit + tailbits <= BIPEB) {
CopyInWord(toblock, frombit, frombit + tailbits - 1, *fromblock,
(tobit - frombit));
frombit += tailbits;
} else {
CopyInWord(toblock, frombit, BIPEB - 1, *fromblock,
(tobit - frombit));
fromblock++;
CopyInWord(toblock, 0, tailbits + frombit - 1 - BIPEB,
fromblock[1], tobit + BIPEB - frombit);
frombit += tailbits - BIPEB;
}
toblock++;
nbits -= tailbits;
tobit = 0;
}
// Main loop for long copies fills whole blocks of destination
UInt m1 = MaskForCopyBits(frombit, BIPEB - 1); while (nbits >= BIPEB) {
x = (*fromblock++ & m1) >> frombit;
x |= (*fromblock & ~m1) << (BIPEB - frombit);
*toblock++ = x;
nbits -= BIPEB;
}
// Finally we may need to fill up a partial block at destination if (nbits) { if (frombit + nbits <= BIPEB) {
CopyInWord(toblock, frombit, frombit + nbits - 1, *fromblock,
-frombit);
} else {
CopyInWord(toblock, frombit, BIPEB - 1, *fromblock, -frombit);
fromblock++;
nbits -= BIPEB - frombit;
tobit = BIPEB - frombit;
CopyInWord(toblock, 0, nbits - 1, *fromblock, tobit);
}
}
}
#endif
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-09-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.