Skip to content

Commit

Permalink
net,vweb: reduce allocations by ~80%
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Nov 10, 2023
1 parent b3a9701 commit e7cad4f
Show file tree
Hide file tree
Showing 12 changed files with 464 additions and 91 deletions.
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
## V 0.4.3
*10 November 2023*

#### Improvements in the language
- Remove additional line breaks after call_expr before params struct args (#19795)

#### Breaking changes

#### Checker improvements/fixes
- Fix comptime enumdata value property access (#19768)
- Fix `field ?&Type` without default value (#19786)
- Avoid nil assign to option var (#19746)

#### Parser improvements
- ast: add missing docstrings for the public fns in vlib/v/ast/types.v (#19752)
- parser: give a friendly error when misusing if over $if (#19810)
- Add multiple struct attributes error for new attribute syntax

#### Compiler internals
- transformer: fix using a constant, instead of a fn parameter with the same name (fix #19766) (#19773)

#### Standard library
- vlib: add an `encoding.xml` module with parser, validation, entity encoding, unit tests (#19708)
- os: implement os.fd_is_pending/1, os.Process.pipe_read/1, os.Process.is_pending/1 (#19787)
- builtin: copy min/max integer values consts from `math` to builtin so that the entire math module doesn't have to be imported(#19809)

#### Web
- flag,json,net: handle C calls in .v files (part of enabling `-W impure-v` as default) (#19779)
- net.http: add socks5|http(s) proxy support [Linux] (#19676)

#### ORM

#### Database drivers

#### Native backend

#### C backend
- Only generate free in wrapper for spawn and not go (#19780)
- Fix g.obf_table data missing(fix #19695) (#19778)
- Fix closure variable in smartcast (#19796)

#### Tools
- tools: fix resolving external dependencies in vpm, add test (#19772)
- tools: cleanup and simplify vcreate, for upcoming fixes and features (#19794)
- tools: improve error messages, add color coding and debug logging (#19781)
- tools: fix `v build-tools`, make `v test` more robust (#19803)
- tools: add parse_query to vpm (#19814)
- ci: add macos arm64 binary release (#19823)
- Require the presence of a `v.mod` file, to install external urls via vpm (#19825)

#### Operating System support

#### Examples
- tests: workaround name conflict, causing false positives with msvc on windows, when both tests were executed at the same time (locked executable)


## V 0.4.2
*30 September 2023*

Expand Down
19 changes: 19 additions & 0 deletions cmd/tools/changelog_helper.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ enum Category {
examples
}

/*
#### Improvements in the language
#### Breaking changes
#### Checker improvements/fixes
#### Parser improvements
#### Compiler internals
#### Standard library
#### Web
#### ORM
#### Database drivers
#### Native backend
#### C backend
#### Tools
#### Operating System support
#### Examples
*/

struct Line {
category Category
text string
Expand All @@ -37,6 +54,8 @@ mut:
fn main() {
if !os.exists(log_txt) {
os.execute(git_log_cmd + ' > ' + log_txt)
println('log.txt generated, remove unnecessary commits from it and run the tool again')
return
}
lines := os.read_lines(log_txt)!
changelog_txt := os.read_file('CHANGELOG.md')!.to_lower()
Expand Down
14 changes: 14 additions & 0 deletions vlib/builtin/string.v
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,20 @@ pub fn (s string) substr(start int, _end int) string {
return res
}

// substr_unsafe works like substr(), but doesn't copy (allocate) the substring
[direct_array_access]
pub fn (s string) substr_unsafe(start int, _end int) string {
end := if _end == 2147483647 { s.len } else { _end } // max_int
len := end - start
if len == s.len {
return s
}
return string{
str: unsafe { s.str + start }
len: len
}
}

// version of `substr()` that is used in `a[start..end] or {`
// return an error when the index is out of range
[direct_array_access]
Expand Down
5 changes: 3 additions & 2 deletions vlib/net/http/cookie.v
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ pub fn read_set_cookies(h map[string][]string) []&Cookie {
// returns the successfully parsed Cookies.
//
// if `filter` isn't empty, only cookies of that name are returned
pub fn read_cookies(h map[string][]string, filter string) []&Cookie {
lines := h['Cookie']
pub fn read_cookies(h Header, filter string) []&Cookie {
// lines := h['Cookie']
lines := h.values(.cookie) // or {
if lines.len == 0 {
return []
}
Expand Down
Loading

0 comments on commit e7cad4f

Please sign in to comment.