Skip to content

Commit 549e11b

Browse files
committed
string: optimize is_ascii()
1 parent 70b33fc commit 549e11b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

thirdparty/sokol/sokol_app.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,6 +3907,7 @@ _SOKOL_PRIVATE void _sapp_macos_frame(void) {
39073907
@implementation _sapp_macos_app_delegate
39083908
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification {
39093909
_SOKOL_UNUSED(aNotification);
3910+
39103911
_sapp_macos_init_cursors();
39113912
if ((_sapp.window_width == 0) || (_sapp.window_height == 0)) {
39123913
// use 4/5 of screen size as default size
@@ -4104,7 +4105,17 @@ keyEquivalent:@"v"];
41044105
_sapp_macos_update_dimensions();
41054106
[NSEvent setMouseCoalescingEnabled:NO];
41064107

4108+
41074109
// __v_ start
4110+
/*
4111+
NSApplicationPresentationOptions options = (NSApplicationPresentationAutoHideMenuBar |
4112+
NSApplicationPresentationAutoHideDock |
4113+
NSApplicationPresentationFullScreen |
4114+
NSApplicationPresentationHideDock);
4115+
4116+
[NSApp setPresentationOptions:options];
4117+
*/
4118+
41084119
//[NSEvent setMouseCoalescingEnabled:NO];
41094120
// __v_ end
41104121
}

vlib/builtin/string.v

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2604,7 +2604,12 @@ pub fn (name string) match_glob(pattern string) bool {
26042604
// is_ascii returns true if all characters belong to the US-ASCII set ([` `..`~`])
26052605
@[inline]
26062606
pub fn (s string) is_ascii() bool {
2607-
return !s.bytes().any(it < u8(` `) || it > u8(`~`))
2607+
for i := 0; i < s.len; i++ {
2608+
if s[i] < u8(` `) || s[i] > u8(`~`) {
2609+
return false
2610+
}
2611+
}
2612+
return true
26082613
}
26092614

26102615
// camel_to_snake convert string from camelCase to snake_case

0 commit comments

Comments
 (0)