1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

map: rename size to len

This commit is contained in:
ka-weihe
2020-06-21 16:51:02 +02:00
committed by GitHub
parent fbe5599526
commit 7f225f2eaa
10 changed files with 116 additions and 116 deletions

View File

@@ -249,7 +249,7 @@ fn (req &Request) method_and_url_to_response(method string, url urllib.URL) ?Res
host_name := url.hostname()
scheme := url.scheme
p := url.path.trim_left('/')
path := if url.query().size > 0 { '/$p?${url.query().encode()}' } else { '/$p' }
path := if url.query().len > 0 { '/$p?${url.query().encode()}' } else { '/$p' }
mut nport := url.port().int()
if nport == 0 {
if scheme == 'http' {

View File

@@ -879,7 +879,7 @@ fn parse_query_values(mut m Values, query string) ?bool {
// encode encodes the values into ``URL encoded'' form
// ('bar=baz&foo=quux') sorted by key.
pub fn (v Values) encode() string {
if v.size == 0 {
if v.len == 0 {
return ''
}
mut buf := strings.new_builder(200)

View File

@@ -11,7 +11,7 @@ pub mut:
struct Values {
pub mut:
data map[string]Value
size int
len int
}
// new_values returns a new Values struct for creating
@@ -35,7 +35,7 @@ pub fn (v &Value) all() []string {
// If there are no values associated with the key, get returns
// a empty string.
pub fn (v &Values) get(key string) string {
if v.data.size == 0 {
if v.data.len == 0 {
return ''
}
vs := v.data[key]
@@ -49,7 +49,7 @@ pub fn (v &Values) get(key string) string {
// If there are no values associated with the key, get returns
// a empty []string.
pub fn (v &Values) get_all(key string) []string {
if v.data.size == 0 {
if v.data.len == 0 {
return []
}
vs := v.data[key]
@@ -65,7 +65,7 @@ pub fn (mut v Values) set(key, value string) {
mut a := v.data[key]
a.data = [value]
v.data[key] = a
v.size = v.data.size
v.len = v.data.len
}
// add adds the value to key. It appends to any existing
@@ -77,11 +77,11 @@ pub fn (mut v Values) add(key, value string) {
}
a.data << value
v.data[key] = a
v.size = v.data.size
v.len = v.data.len
}
// del deletes the values associated with key.
pub fn (mut v Values) del(key string) {
v.data.delete(key)
v.size = v.data.size
v.len = v.data.len
}