Skip to content

Commit 16524a0

Browse files
committed
Merge pull request #156 from sparkprime/cleanup_find_object
CLEANUP: Remove unnecessary params from findObject
2 parents a62a717 + 28e874e commit 16524a0

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

core/vm.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -565,33 +565,28 @@ class Interpreter {
565565
* with the given field. Call with offset initially set to 0.
566566
*
567567
* \param f The field we're looking for.
568-
* \param curr The root object.
569568
* \param start_from Step over this many leaves first.
570569
* \param counter Return the level of "super" that contained the field.
571-
* \param self Return the new root.
572570
* \returns The first object with the field, or nullptr if it could not be found.
573571
*/
574-
HeapLeafObject *findObject(const Identifier *f, HeapObject *root, HeapObject *curr,
575-
unsigned start_from, unsigned &counter,
576-
HeapObject *&self)
572+
HeapLeafObject *findObject(const Identifier *f, HeapObject *curr,
573+
unsigned start_from, unsigned &counter)
577574
{
578575
if (auto *ext = dynamic_cast<HeapExtendedObject*>(curr)) {
579-
auto *r = findObject(f, root, ext->right, start_from, counter, self);
576+
auto *r = findObject(f, ext->right, start_from, counter);
580577
if (r) return r;
581-
auto *l = findObject(f, root, ext->left, start_from, counter, self);
578+
auto *l = findObject(f, ext->left, start_from, counter);
582579
if (l) return l;
583580
} else {
584581
if (counter >= start_from) {
585582
if (auto *simp = dynamic_cast<HeapSimpleObject*>(curr)) {
586583
auto it = simp->fields.find(f);
587584
if (it != simp->fields.end()) {
588-
self = root;
589585
return simp;
590586
}
591587
} else if (auto *comp = dynamic_cast<HeapComprehensionObject*>(curr)) {
592588
auto it = comp->compValues.find(f);
593589
if (it != comp->compValues.end()) {
594-
self = root;
595590
return comp;
596591
}
597592
}
@@ -847,8 +842,8 @@ class Interpreter {
847842
const Identifier *f, unsigned offset)
848843
{
849844
unsigned found_at = 0;
850-
HeapObject *self = nullptr;
851-
HeapLeafObject *found = findObject(f, obj, obj, offset, found_at, self);
845+
HeapObject *self = obj;
846+
HeapLeafObject *found = findObject(f, obj, offset, found_at);
852847
if (found == nullptr) {
853848
throw makeError(loc, "Field does not exist: " + encode_utf8(f->name));
854849
}

0 commit comments

Comments
 (0)