From f698d347ac61453c72e3002d2585f0999b36b691 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 1 Jul 2007 15:47:26 -0600 Subject: [PATCH] eliminate conditional when calculating object size --- src/vm.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/vm.cpp b/src/vm.cpp index 7235b52ad4..31d43661a6 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -492,14 +492,10 @@ collect(Machine* m, Heap::CollectionType type) p = m->heap->follow(mask(p)); object class_ = m->heap->follow(objectClass(t, p)); - unsigned n = divide(classFixedSize(t, class_), BytesPerWord); - - if (classArrayElementSize(t, class_)) { - n += divide(classArrayElementSize(t, class_) - * cast(p, classFixedSize(t, class_) - 4), - BytesPerWord); - } - return n; + return divide(classFixedSize(t, class_), BytesPerWord) + + divide(classArrayElementSize(t, class_) + * cast(p, classFixedSize(t, class_) - 4), + BytesPerWord); } virtual void walk(void* p, Heap::Walker* w) { @@ -764,15 +760,10 @@ objectSize(Thread* t, object o) { object class_ = objectClass(t, o); - unsigned n = divide(classFixedSize(t, class_), BytesPerWord); - - if (classArrayElementSize(t, class_)) { - n += divide(classArrayElementSize(t, class_) - * cast(o, classFixedSize(t, class_) - 4), - BytesPerWord); - } - - return n; + return divide(classFixedSize(t, class_), BytesPerWord) + + divide(classArrayElementSize(t, class_) + * cast(o, classFixedSize(t, class_) - 4), + BytesPerWord); } object