Skip to content

Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.

C

refactor: the Lyricsfile reader builds its digit set once

My-Name-Is-Jeff05f63aab7ae5
diff --git a/tweak/Sources/Shared/LyricsSources/Lyricsfile.m b/tweak/Sources/Shared/LyricsSources/Lyricsfile.m
index 05313d67..80d1d261 100644
--- a/tweak/Sources/Shared/LyricsSources/Lyricsfile.m
+++ b/tweak/Sources/Shared/LyricsSources/Lyricsfile.m
@@ -290,8 +290,11 @@ static const NSUInteger kMaxLength = 1 << 18;
// A time in milliseconds: ASCII digits only, none negative, and at most nine of them (over a hundred
// hours), so the sums below cannot overflow. -1 for anything else.
static NSInteger msOf(id value) {
+ static NSCharacterSet *notDigits;
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{ notDigits = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"].invertedSet; });
if (![value isKindOfClass:NSString.class] || ![value length] || [value length] > 9) return -1;
- if ([value rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"0123456789"].invertedSet].location != NSNotFound) return -1;
+ if ([value rangeOfCharacterFromSet:notDigits].location != NSNotFound) return -1;
return [value integerValue];
}