That's not it.
I'd say this is a terrible code to have in a library because it is supposed to handle things that are different and are not supposed to be treated or handled the same way.
For starters it is handling scripts and witnesses which are entirely different things. Scripts are scripts! They contain OP codes including PUSHDATA and are supposed to be interpreted to "build" the stack with the "operations" you have to perform. Hence the 4 branches handling 0x4c,0x4d,0x4e.
On the other hand witness is already a stack, it is not-supposed to be interpreted and it does not include OP codes including PUSHDATA. It only has count and size. The code also assumes you have read and discarded the count.
In simple terms this method handles apples and oranges at the same time which is why it looks weird.
In a script you have OP_PUSHDATA1 so the first 4 branches handle those with a condition that it is not-witness so that they know what data to "push to the stack" while the last branch (the else part) is handling the witness (not SegWit output or address) so it has to read a
var_int (aka compact_int) indicating the size of the item that is already on the stack.