fix(kernel/context): make context remove more robust
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
f728f80960
commit
3e77dd0c42
1 changed files with 9 additions and 5 deletions
|
@ -43,14 +43,18 @@ optional<context_entry> context::find(unsigned i) const {
|
|||
}
|
||||
|
||||
static list<context_entry> remove_core(list<context_entry> const & l, unsigned s, unsigned n) {
|
||||
if (s == 0) {
|
||||
if (n > 0) {
|
||||
return remove_core(tail(l), 0, n-1);
|
||||
if (l) {
|
||||
if (s == 0) {
|
||||
if (n > 0) {
|
||||
return remove_core(tail(l), 0, n-1);
|
||||
} else {
|
||||
return l;
|
||||
}
|
||||
} else {
|
||||
return l;
|
||||
return cons(head(l), remove_core(tail(l), s-1, n));
|
||||
}
|
||||
} else {
|
||||
return cons(head(l), remove_core(tail(l), s-1, n));
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue