End goal = O(1) time ← String.count

No.

> "\r\n".count
Int = 1
> "\r\n".unicodeScalars.count
Int = 2

This sequence, while two unicode scalars, is a single grapheme cluster (in Swift, a single Character.)

What I have done in the past is to operate in the realm of representing fixed-size unicode scalars, and convert to/from that for Swift String types.