2 Commits

Author SHA1 Message Date
spencer 997f11b257 perf: Added a pre-alloc opportunity. 2026-07-03 22:12:08 -04:00
spencer f5624e91f1 perf: Added #no_bounds_check to ssh parsers. 2026-07-03 21:43:06 -04:00
3 changed files with 35 additions and 37 deletions
+4 -7
View File
@@ -6,17 +6,14 @@
3. procedures should be ordered by use, main at the top, then in the order they are called from main.
4. Check for prealloc opportunities. i.e. `make([dynamic]string)` -> `make([dynamic]string, 5)`.
4. Test all command branches.
5. Test all command branches.
5. Generate md and man pages again.
6. Generate md and man pages again.
6. Bash Shell completion
7. Bash Shell completion
7. Add tests for untested commands.
8. Add tests for untested commands.
9. Audit ssh.odin for places where `#no_bounds_check` would be appropriate.
## Double-check AI output
+2 -7
View File
@@ -124,12 +124,7 @@ key somewhere, otherwise your data could be lost forever.`,
flags = GLOBAL_FLAGS,
args = {{name = "path", optional = true}},
},
{
name = "version",
usage = "envr version",
short = "Show envr's version",
flags = {.Help},
},
{name = "version", usage = "envr version", short = "Show envr's version", flags = {.Help}},
{
name = "edit-config",
usage = "envr edit-config",
@@ -160,7 +155,7 @@ parse_args :: proc(args: []string, out: io.Stream, err: io.Stream) -> (cmd: Comm
}
cmd.name = args[1]
cmd.args = make([dynamic]string)
cmd.args = make([dynamic]string, 0, len(args[2:]))
overflow := parse_flags(&cmd.flags, args[2:])
for arg in overflow {
+11 -5
View File
@@ -164,20 +164,26 @@ is_ed25519_key :: proc(
return ok, nil
}
read_wire_string :: proc(data: ^[]u8) -> (s: []u8, ok: bool) {
if len(data^) < 4 do return
read_wire_string :: proc(data: ^[]u8) -> (s: []u8, ok: bool) #no_bounds_check {
if len(data^) < 4 {
return
}
length := endian.get_u32(data^[:4], .Big) or_return
data^ = data^[4:]
if len(data^) < int(length) do return
if len(data^) < int(length) {
return
}
s = data^[:int(length)]
data^ = data^[int(length):]
ok = true
return
}
read_wire_u32 :: proc(data: ^[]u8) -> (v: u32, ok: bool) {
if len(data^) < 4 do return
read_wire_u32 :: proc(data: ^[]u8) -> (v: u32, ok: bool) #no_bounds_check {
if len(data^) < 4 {
return
}
v = endian.get_u32(data^[:4], .Big) or_return
data^ = data^[4:]
ok = true