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

bf: minor clean up

This commit is contained in:
Alexander Medvednikov 2019-09-08 18:53:40 +03:00
parent f70d206881
commit a6ec6e23bc
2 changed files with 13 additions and 8 deletions

View File

@ -1044,8 +1044,9 @@ fn (p mut Parser) statements_no_rcbr() string {
fn (p mut Parser) close_scope() {
// println('close_scope level=$f.scope_level var_idx=$f.var_idx')
// Move back `var_idx` (pointer to the end of the array) till we reach the previous scope level.
// This effectivly deletes (closes) current scope.
// Move back `var_idx` (pointer to the end of the array) till we reach
// the previous scope level. This effectivly deletes (closes) current
// scope.
mut i := p.cur_fn.var_idx - 1
for ; i >= 0; i-- {
v := p.cur_fn.local_vars[i]
@ -1055,7 +1056,12 @@ fn (p mut Parser) close_scope() {
}
if p.pref.building_v && v.is_alloc {
if v.typ.starts_with('array_') {
p.genln('v_array_free($v.name); // close_scope free')
if false && p.returns {
prev_line := p.cgen.lines[p.cgen.lines.len-2]
p.cgen.lines[p.cgen.lines.len-2] = 'v_array_free($v.name); /*close_scope free */' + prev_line
} else {
p.genln('v_array_free($v.name); // close_scope free')
}
}
else if v.typ == 'string' {
//p.genln('v_string_free($v.name); // close_scope free')

View File

@ -476,10 +476,9 @@ pub fn (instance mut BitField) reverse() BitField {
return output
}
// resize() changes the size of the bit array to 'new_size'
pub fn (instance mut BitField) resize(size int) {
new_bitnslots := bitnslots(size)
// resize changes the size of the bit array to 'new_size'
pub fn (instance mut BitField) resize(new_size int) {
new_bitnslots := bitnslots(new_size)
old_size := instance.size
old_bitnslots := bitnslots(old_size)
mut field := [u32(0); new_bitnslots]
@ -487,7 +486,7 @@ pub fn (instance mut BitField) resize(size int) {
field[i] = instance.field[i]
}
instance.field = field.clone()
instance.size = size
instance.size = new_size
if size < old_size && size % SLOT_SIZE != 0 {
cleartail(mut instance)
}