net,vweb: reduce allocations by ~80%

This commit is contained in:
Alexander Medvednikov 2023-11-11 01:10:23 +03:00
parent b3a9701129
commit e7cad4f55d
12 changed files with 464 additions and 91 deletions

View file

@ -98,7 +98,12 @@ pub fn (mut r Response) set_status(s Status) {
// version parses the version
pub fn (r Response) version() Version {
return version_from_str('HTTP/${r.http_version}')
return match r.http_version {
'1.0' { .v1_0 }
'1.1' { .v1_1 }
'2.0' { .v2_0 }
else { .unknown }
}
}
// set_version sets the http_version string of the response