Skip to content

Commit

Permalink
string: optimize is_ascii()
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Jun 22, 2024
1 parent 70b33fc commit 549e11b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions thirdparty/sokol/sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 6 additions & 1 deletion vlib/builtin/string.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 549e11b

Please sign in to comment.