From ab91733a2854fac4d85e4713fe836b6479b4102a Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Fri, 22 Nov 2019 18:55:20 +1100 Subject: [PATCH] small optimization with generics and use os.is_dir in vweb again --- vlib/compiler/fn.v | 10 ++++------ vlib/vweb/vweb.v | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/vlib/compiler/fn.v b/vlib/compiler/fn.v index 74a6b65280..1d608b0b5a 100644 --- a/vlib/compiler/fn.v +++ b/vlib/compiler/fn.v @@ -1370,13 +1370,11 @@ fn (p mut Parser) save_generic_tmpl(f mut Fn, pos int) { fn (f &Fn) generic_tmpl_to_inst(ti TypeInst) string { mut fn_body := '' for tok in f.generic_tmpl { - mut toks := tok.str() - if toks in ti.inst { - for k,v in ti.inst { - toks = toks.replace(k, v) - } + mut tok_str := tok.str() + if tok.tok == .name && tok_str in ti.inst { + tok_str = ti.inst[tok_str] } - fn_body += ' $toks' + fn_body += ' $tok_str' } return fn_body } diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index c02fbfd882..7914e5e4b7 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -216,7 +216,8 @@ fn (ctx mut Context) scan_static_directory(directory_path, mount_path string) { } // todo: os.is_dir is broken now so we expect that file is dir it has no extension - if flag { + // if flag { + if os.is_dir(file) { ctx.scan_static_directory(directory_path + '/' + file, mount_path + '/' + file) } else { ctx.static_files[mount_path + '/' + file] = directory_path + '/' + file