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

migrate remaining code to the new maps

This commit is contained in:
Alexander Medvednikov 2019-07-14 22:26:21 +02:00
parent f7dbbf5810
commit 3b1964e9df
4 changed files with 4 additions and 12 deletions

View File

@ -26,10 +26,7 @@ fn main() {
m[key] = m[key] + 1// TODO m[key]++ m[key] = m[key] + 1// TODO m[key]++
} }
// Sort the keys // Sort the keys
mut keys := []string mut keys := m.keys()
for e in m.entries {
keys << e.key
}
keys.sort() keys.sort()
// Print the map // Print the map
for key in keys { for key in keys {

View File

@ -202,7 +202,7 @@ pub fn (m map_string) str() string {
} }
// TODO use bytes buffer // TODO use bytes buffer
mut s := '{\n' mut s := '{\n'
//for entry in m.entries { //for key, val in m {
//val := m[entry.key] //val := m[entry.key]
//s += ' "$entry.key" => "$val"\n' //s += ' "$entry.key" => "$val"\n'
//} //}

View File

@ -124,9 +124,7 @@ fn (req &Request) do() Response {
// Add request headers // Add request headers
mut hlist := &C.curl_slist{!} mut hlist := &C.curl_slist{!}
// for i, h := range req.headers { // for i, h := range req.headers {
for entry in req.headers.entries { for key, val in req.headers {
key := entry.key
val := req.headers[key]
h := '$key: $val' h := '$key: $val'
hlist = C.curl_slist_append(hlist, h.cstr()) hlist = C.curl_slist_append(hlist, h.cstr())
} }

View File

@ -42,10 +42,7 @@ fn (req &Request) do() Response {
mut headers := '' mut headers := ''
mut resp_headers := '' mut resp_headers := ''
// for header in req.headers { // for header in req.headers {
for entry in req.headers.entries { for key, val in req.headers {
// headers += '$header\r\n'
key := entry.key
val := req.headers[key]
headers += '$key: $val\r\n' headers += '$key: $val\r\n'
} }
if req.typ == 'POST' { if req.typ == 'POST' {