One possible use for this kind of coding is implementing an encryption algorithm. I've used this in DES and S-boxes, although it was a while ago. The key point is that performance matters. You need something fast.
My recommendation is to precompute the masks and unroll the loop. For your 4 bit example:
int bits[4] = { 1, 2, 4, 8 };
result = (bits[table[0]] & source)
| (bits[table[1]] & source)
| (bits[table[2]] & source)
| (bits[table[3]] & source);
[I don't think this is the right algorithm, but it matches the question.]
But I would check the generated code. A good enough optimising compiler could convert your code into exactly this!