A more efficient Str.samecase