Right now this code is only used to convert boolean arrays to bits (e.g. for faster `IndexMask` generation). This patch extracts a more general function that converts bytes to bits using a rule that is passed in as parameter. This may become useful to speedup parsing e.g. CSV files to speedup detection of delimiters and other special byte values. This code is already covered by unit tests, so no new tests have been added. Pull Request: https://projects.blender.org/blender/blender/pulls/134798