Performance optimization in isString() and $() for string primitives