mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-24 06:55:15 +00:00
Keep 0 in counting map
This commit is contained in:
parent
e29af85dcf
commit
079290dcaf
5 changed files with 10 additions and 20 deletions
|
@ -378,12 +378,6 @@ fn specialize_drops_stmt<'a, 'i>(
|
|||
(info.clone(), new_branch)
|
||||
};
|
||||
|
||||
// Remove all 0 counts as cleanup.
|
||||
environment
|
||||
.incremented_symbols
|
||||
.map
|
||||
.retain(|_, count| *count > 0);
|
||||
|
||||
arena.alloc(Stmt::Switch {
|
||||
cond_symbol: *cond_symbol,
|
||||
cond_layout: *cond_layout,
|
||||
|
@ -395,7 +389,7 @@ fn specialize_drops_stmt<'a, 'i>(
|
|||
Stmt::Ret(symbol) => arena.alloc(Stmt::Ret(*symbol)),
|
||||
Stmt::Refcounting(rc, continuation) => match rc {
|
||||
ModifyRc::Inc(symbol, count) => {
|
||||
let any = environment.incremented_symbols.contains(symbol);
|
||||
let inc_before = environment.incremented_symbols.contained(symbol);
|
||||
|
||||
// Add a symbol for every increment performed.
|
||||
environment
|
||||
|
@ -410,7 +404,7 @@ fn specialize_drops_stmt<'a, 'i>(
|
|||
continuation,
|
||||
);
|
||||
|
||||
if any {
|
||||
if inc_before {
|
||||
// There were increments before this one, best to let the first one do the increments.
|
||||
// Or there are no increments left, so we can just continue.
|
||||
new_continuation
|
||||
|
@ -1540,10 +1534,7 @@ where
|
|||
|
||||
fn pop(&mut self, key: &K) -> bool {
|
||||
match self.map.get_mut(key) {
|
||||
Some(1) => {
|
||||
self.map.remove(key);
|
||||
true
|
||||
}
|
||||
Some(0) => false,
|
||||
Some(c) => {
|
||||
*c -= 1;
|
||||
true
|
||||
|
@ -1552,7 +1543,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn contains(&self, symbol: &K) -> bool {
|
||||
fn contained(&self, symbol: &K) -> bool {
|
||||
self.map.contains_key(symbol)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ procedure Decode.26 (Decode.105, Decode.106):
|
|||
procedure Decode.27 (Decode.107, Decode.108):
|
||||
let Decode.122 : {List U8, [C {}, C Str]} = CallByName Decode.26 Decode.107 Decode.108;
|
||||
let Decode.110 : List U8 = StructAtIndex 0 Decode.122;
|
||||
let Decode.109 : [C {}, C Str] = StructAtIndex 1 Decode.122;
|
||||
inc Decode.110;
|
||||
let Decode.109 : [C {}, C Str] = StructAtIndex 1 Decode.122;
|
||||
let Decode.125 : Int1 = CallByName List.1 Decode.110;
|
||||
if Decode.125 then
|
||||
dec Decode.110;
|
||||
|
@ -532,9 +532,9 @@ procedure Json.68 ():
|
|||
procedure Json.69 (Json.1467):
|
||||
joinpoint Json.1197 Json.1165:
|
||||
let Json.599 : List U8 = StructAtIndex 0 Json.1165;
|
||||
inc Json.599;
|
||||
let Json.600 : List U8 = StructAtIndex 1 Json.1165;
|
||||
let Json.1315 : U64 = 0i64;
|
||||
inc Json.599;
|
||||
let Json.601 : [C {}, C U8] = CallByName List.2 Json.599 Json.1315;
|
||||
let Json.1314 : U64 = 1i64;
|
||||
inc Json.599;
|
||||
|
|
|
@ -136,14 +136,13 @@ procedure Test.1 (Test.77):
|
|||
if Test.64 then
|
||||
let Test.52 : [<r>C I64, C List *self] = StructAtIndex 0 Test.6;
|
||||
let Test.12 : List [<r>C I64, C List *self] = UnionAtIndex (Id 1) (Index 0) Test.52;
|
||||
inc Test.12;
|
||||
inc 2 Test.12;
|
||||
let Test.51 : [<r>C I64, C List *self] = StructAtIndex 1 Test.6;
|
||||
dec Test.52;
|
||||
let Test.14 : List [<r>C I64, C List *self] = UnionAtIndex (Id 1) (Index 0) Test.51;
|
||||
inc Test.14;
|
||||
joinpoint #Derived_gen.2:
|
||||
let Test.35 : {} = Struct {};
|
||||
inc Test.12;
|
||||
inc Test.14;
|
||||
let Test.33 : List {[<r>C I64, C List *self], [<r>C I64, C List *self]} = CallByName List.23 Test.12 Test.14 Test.35;
|
||||
let Test.34 : {} = Struct {};
|
||||
let Test.29 : Int1 = CallByName List.56 Test.33 Test.34;
|
||||
|
|
|
@ -506,9 +506,9 @@ procedure Json.68 ():
|
|||
procedure Json.69 (Json.1467):
|
||||
joinpoint Json.1197 Json.1165:
|
||||
let Json.599 : List U8 = StructAtIndex 0 Json.1165;
|
||||
inc Json.599;
|
||||
let Json.600 : List U8 = StructAtIndex 1 Json.1165;
|
||||
let Json.1315 : U64 = 0i64;
|
||||
inc Json.599;
|
||||
let Json.601 : [C {}, C U8] = CallByName List.2 Json.599 Json.1315;
|
||||
let Json.1314 : U64 = 1i64;
|
||||
inc Json.599;
|
||||
|
|
|
@ -203,8 +203,8 @@ procedure Test.3 (Test.9, Test.10, Test.11):
|
|||
let Test.173 : Int1 = true;
|
||||
let Test.177 : Int1 = lowlevel Eq Test.173 Test.172;
|
||||
if Test.177 then
|
||||
let #Derived_gen.272 : [<rnu>C *self I64 *self I32 Int1, <null>] = Reset { symbol: Test.16, id: UpdateModeId { id: 242 } };
|
||||
inc Test.19;
|
||||
let #Derived_gen.272 : [<rnu>C *self I64 *self I32 Int1, <null>] = Reset { symbol: Test.16, id: UpdateModeId { id: 242 } };
|
||||
let Test.118 : [<rnu>C *self I64 *self I32 Int1, <null>] = CallByName Test.3 Test.19 Test.10 Test.11;
|
||||
joinpoint Test.137 #Derived_gen.317 #Derived_gen.318:
|
||||
let Test.136 : [<rnu>C *self I64 *self I32 Int1, <null>] = UnionAtIndex (Id 1) (Index 0) Test.118;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue