Skip to content

Commit eb1e36d

Browse files
committed
Use length-aware NSString initializer in StringTokenToNSString
Avoids a redundant strlen walk by passing es_str.length directly to NSString rather than relying on the data field's NUL terminator.
1 parent f0d9ae7 commit eb1e36d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Source/common/String.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ static inline NSString* StringTokenToNSString(es_string_token_t es_str) {
6767
if (es_str.length == 0) {
6868
return nil;
6969
}
70-
return StringToNSString(es_str.data);
70+
return [[NSString alloc] initWithBytes:es_str.data
71+
length:es_str.length
72+
encoding:NSUTF8StringEncoding];
7173
}
7274

7375
static inline std::string BufToHexString(const uint8_t* buf, size_t bufsize) {

0 commit comments

Comments
 (0)