MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / jsws_trim

Function jsws_trim

codegraph-kernel/src/cfnptr.rs:989–1012  ·  view source on GitHub ↗

JS String.prototype.trim over bytes (the JS set == our jsws set).

(s: &[u8], mut a: usize, mut b: usize)

Source from the content-addressed store, hash-verified

987}
988
989/// JS String.prototype.trim over bytes (the JS set == our jsws set).
990fn jsws_trim(s: &[u8], mut a: usize, mut b: usize) -> (usize, usize) {
991 loop {
992 let l = jsws_len(s, a);
993 if l == 0 || a + l > b {
994 break;
995 }
996 a += l;
997 }
998 // Trailing: walk from the front to find the last non-ws position (ws
999 // lengths vary, so scan forward tracking the end of the last non-ws char).
1000 let mut i = a;
1001 let mut last_end = a;
1002 while i < b {
1003 let l = jsws_len(s, i);
1004 if l == 0 {
1005 i += 1;
1006 last_end = i;
1007 } else {
1008 i += l;
1009 }
1010 }
1011 b = last_end;
1012 (a, b)
1013}
1014
1015/// /(\w+)\s+\**\s*(\w+)\s*$/ — leftmost match whose tail reaches the end.

Callers 1

parse_struct_fields_rawFunction · 0.85

Calls 1

jsws_lenFunction · 0.85

Tested by

no test coverage detected