-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequence equality #249
base: main
Are you sure you want to change the base?
Sequence equality #249
Changes from all commits
1fc35d5
bbc06d0
a059c68
701d79f
8a1472e
cbd354f
3727186
ddd82ac
c2da550
c035ee8
4dc1d92
b6d8889
408ed65
4529d26
c227006
f1d6e2c
ca229f8
3afba55
c5f2e33
2dbbca6
d081d74
4819593
fe6f1dd
2deb82d
c36ca8d
acb06a4
4a1620f
b3ffc63
8bf2c34
6b760d1
0bbcbc1
5a08204
e9c761f
a695a90
31216fc
e8fc0b5
6e26023
02d217d
4979e26
5e1e9c3
fc1ff00
6a1919f
10f4798
bdecaf0
2dc83fe
99728fa
0b8c535
dd3649e
674a8e9
d754b74
6132099
7c16d3a
d9d6281
e562511
0d27f83
64a74a2
eee2c29
cea8422
2e08987
35a8643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -869,7 +869,7 @@ namespace jank::runtime | |
{ | ||
return visit_seqable( | ||
[=](auto const typed_args) -> object_ptr { | ||
auto const s(typed_args->fresh_seq()); | ||
auto s(typed_args->fresh_seq()); | ||
auto const length(sequence_length(s, max_params + 1)); | ||
switch(length) | ||
{ | ||
|
@@ -878,88 +878,88 @@ namespace jank::runtime | |
case 1: | ||
return dynamic_call(source, s->first()); | ||
case 2: | ||
return dynamic_call(source, s->first(), s->next_in_place()->first()); | ||
return dynamic_call(source, s->first(), (s = s->next_in_place())->first()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a local TODO that notes that This change is a big red flag, since this is an extremely hot code path. I don't want to impact its perf for this one case which needs to change anyway. If you want to add a comment here noting that it doesn't work for Either way, let's please undo this file's changes. |
||
case 3: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first()); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first()); | ||
case 4: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first()); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first()); | ||
case 5: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first()); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first()); | ||
case 6: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first()); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first()); | ||
case 7: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first()); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first()); | ||
case 8: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first()); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first()); | ||
case 9: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first()); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first()); | ||
case 10: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first()); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first()); | ||
default: | ||
return dynamic_call(source, | ||
s->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
s->next_in_place()->first(), | ||
obj::persistent_list::create(next_in_place(s))); | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
(s = s->next_in_place())->first(), | ||
obj::persistent_list::create(s = next_in_place(s))); | ||
} | ||
}, | ||
args); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -243,9 +243,10 @@ namespace jank::runtime | |
{ | ||
return !rhs; | ||
} | ||
else if(!rhs) | ||
if(!rhs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the |
||
{ | ||
return !lhs; | ||
assert(lhs); | ||
return false; | ||
} | ||
|
||
return visit_object([&](auto const typed_lhs) { return typed_lhs->equal(*rhs); }, lhs); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,12 +162,15 @@ namespace jank::runtime::obj | |
for(auto it(fresh_seq()); it != nullptr; | ||
it = runtime::next_in_place(it), seq = runtime::next_in_place(seq)) | ||
{ | ||
if(seq == nullptr || !runtime::equal(it, seq->first())) | ||
assert(it != nil::nil_const()); | ||
assert(seq != nil::nil_const()); | ||
Comment on lines
+165
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's impossible for these assertions to be false, proven by the type system. I think you're concerned about the Now, the history is that Either way, your concerns about this being nil should not be keeping you up. |
||
if(seq == nullptr || !runtime::equal(it->first(), seq->first())) | ||
{ | ||
return false; | ||
} | ||
} | ||
return true; | ||
assert(seq != nil::nil_const()); | ||
return seq == nullptr; | ||
}, | ||
[]() { return false; }, | ||
&o); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,12 +77,15 @@ namespace jank::runtime::obj | |
for(auto it(fresh_seq()); it != nullptr; | ||
it = runtime::next_in_place(it), seq = runtime::next_in_place(seq)) | ||
{ | ||
if(seq == nullptr || !runtime::equal(it, seq->first())) | ||
assert(it != nil::nil_const()); | ||
assert(seq != nil::nil_const()); | ||
if(seq == nullptr || !runtime::equal(it->first(), seq->first())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a good fix. We'd need the same thing for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Done.
Several places. I think I reverted some of them accidentally when experimenting with replace
I wasn't sure how to tackle it, but I can at least write more tests so then the abstraction can be validated easily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't worry about removing support for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I have some ideas for how to do it. The tests are very welcome, though. |
||
{ | ||
return false; | ||
} | ||
} | ||
return true; | ||
assert(seq != nil::nil_const()); | ||
return seq == nullptr; | ||
}, | ||
[]() { return false; }, | ||
&o); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed in slack, none of these assertions on native boxes are needed. It has its own.