string: optimize is_ascii()

This commit is contained in:
Alexander Medvednikov 2024-06-22 15:58:18 +03:00
parent 70b33fc303
commit 549e11bfa1
2 changed files with 17 additions and 1 deletions

View File

@ -3907,6 +3907,7 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
@implementation _sapp_macos_app_delegate
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
_SOKOL_UNUSED(aNotification);
_sapp_macos_init_cursors();
if ((_sapp.window_width == 0) || (_sapp.window_height == 0)) {
// use 4/5 of screen size as default size
@ -4104,7 +4105,17 @@ keyEquivalent:@"v"];
_sapp_macos_update_dimensions();
[NSEvent setMouseCoalescingEnabled:NO];
// __v_ start
/*
NSApplicationPresentationOptions options = (NSApplicationPresentationAutoHideMenuBar |
NSApplicationPresentationAutoHideDock |
NSApplicationPresentationFullScreen |
NSApplicationPresentationHideDock);
[NSApp setPresentationOptions:options];
*/
//[NSEvent setMouseCoalescingEnabled:NO];
// __v_ end
}

View File

@ -2604,7 +2604,12 @@ pub fn (name string) match_glob(pattern string) bool {
// is_ascii returns true if all characters belong to the US-ASCII set ([` `..`~`])
@[inline]
pub fn (s string) is_ascii() bool {
return !s.bytes().any(it < u8(` `) || it > u8(`~`))
for i := 0; i < s.len; i++ {
if s[i] < u8(` `) || s[i] > u8(`~`) {
return false
}
}
return true
}
// camel_to_snake convert string from camelCase to snake_case