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:
parent
f70d206881
commit
a6ec6e23bc
@ -1044,8 +1044,9 @@ fn (p mut Parser) statements_no_rcbr() string {
|
|||||||
|
|
||||||
fn (p mut Parser) close_scope() {
|
fn (p mut Parser) close_scope() {
|
||||||
// println('close_scope level=$f.scope_level var_idx=$f.var_idx')
|
// 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.
|
// Move back `var_idx` (pointer to the end of the array) till we reach
|
||||||
// This effectivly deletes (closes) current scope.
|
// the previous scope level. This effectivly deletes (closes) current
|
||||||
|
// scope.
|
||||||
mut i := p.cur_fn.var_idx - 1
|
mut i := p.cur_fn.var_idx - 1
|
||||||
for ; i >= 0; i-- {
|
for ; i >= 0; i-- {
|
||||||
v := p.cur_fn.local_vars[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 p.pref.building_v && v.is_alloc {
|
||||||
if v.typ.starts_with('array_') {
|
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' {
|
else if v.typ == 'string' {
|
||||||
//p.genln('v_string_free($v.name); // close_scope free')
|
//p.genln('v_string_free($v.name); // close_scope free')
|
||||||
|
@ -476,10 +476,9 @@ pub fn (instance mut BitField) reverse() BitField {
|
|||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
// resize() changes the size of the bit array to 'new_size'
|
// resize changes the size of the bit array to 'new_size'
|
||||||
|
pub fn (instance mut BitField) resize(new_size int) {
|
||||||
pub fn (instance mut BitField) resize(size int) {
|
new_bitnslots := bitnslots(new_size)
|
||||||
new_bitnslots := bitnslots(size)
|
|
||||||
old_size := instance.size
|
old_size := instance.size
|
||||||
old_bitnslots := bitnslots(old_size)
|
old_bitnslots := bitnslots(old_size)
|
||||||
mut field := [u32(0); new_bitnslots]
|
mut field := [u32(0); new_bitnslots]
|
||||||
@ -487,7 +486,7 @@ pub fn (instance mut BitField) resize(size int) {
|
|||||||
field[i] = instance.field[i]
|
field[i] = instance.field[i]
|
||||||
}
|
}
|
||||||
instance.field = field.clone()
|
instance.field = field.clone()
|
||||||
instance.size = size
|
instance.size = new_size
|
||||||
if size < old_size && size % SLOT_SIZE != 0 {
|
if size < old_size && size % SLOT_SIZE != 0 {
|
||||||
cleartail(mut instance)
|
cleartail(mut instance)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user