diff --git a/compiler/parser.v b/compiler/parser.v index f813ec486f..4781eafeed 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1686,7 +1686,7 @@ fn (p mut Parser) bterm() string { // also called on *, &, @, . (enum) fn (p mut Parser) name_expr() string { - //println('n') +//println('n') p.has_immutable_field = false p.is_const_literal = false ph := p.cgen.add_placeholder() diff --git a/compiler/table.v b/compiler/table.v index ead5aec864..aaffdb60cf 100644 --- a/compiler/table.v +++ b/compiler/table.v @@ -31,7 +31,6 @@ struct VargAccess { index int } -/* enum NameCategory { constant mod @@ -41,8 +40,8 @@ enum NameCategory { struct Name { cat NameCategory + idx int // e.g. typ := types[name.idx] } -*/ struct GenTable { fn_name string diff --git a/vlib/builtin/hashmap.v b/vlib/builtin/hashmap.v index 6a9bd9afa5..fca198289e 100644 --- a/vlib/builtin/hashmap.v +++ b/vlib/builtin/hashmap.v @@ -35,7 +35,7 @@ const ( ) fn new_hashmap(planned_nr_items int) hashmap { - mut cap := planned_nr_items * 3 + mut cap := planned_nr_items * 5 if cap < min_cap { cap = min_cap } diff --git a/vlib/builtin/map.v b/vlib/builtin/map.v index c467b8cab2..4110cbbd21 100644 --- a/vlib/builtin/map.v +++ b/vlib/builtin/map.v @@ -177,7 +177,7 @@ pub fn (m &map) keys() []string { } fn (m map) get(key string, out voidptr) bool { - //println('g') + println('g') if m.root == 0 { return false } diff --git a/vlib/runtime/runtime.v b/vlib/runtime/runtime.v new file mode 100644 index 0000000000..842a54487b --- /dev/null +++ b/vlib/runtime/runtime.v @@ -0,0 +1,13 @@ +// Copyright (c) 2019 Alexander Medvednikov. All rights reserved. +// Use of this source code is governed by an MIT license +// that can be found in the LICENSE file. + +module runtime + +#include + +fn C.get_nprocs() int + +pub fn nr_cpus() int { + return C.get_nprocs() +} diff --git a/vlib/runtime/runtime_test.v b/vlib/runtime/runtime_test.v new file mode 100644 index 0000000000..c1cb53d999 --- /dev/null +++ b/vlib/runtime/runtime_test.v @@ -0,0 +1,7 @@ +import runtime + +fn test_nr_cpus() { + nr_cpus := runtime.nr_cpus() + println(nr_cpus) + assert nr_cpus > 0 +}