comparison graal/com.oracle.truffle.object/src/com/oracle/truffle/object/ShapeImpl.java @ 18622:a306a94111a6

OM: iterate over properties using property map instead of parent chain
author Andreas Woess <andreas.woess@jku.at>
date Fri, 28 Nov 2014 15:43:49 +0100
parents b3b241bbbbdb
children 8bf798e8cf11
comparison
equal deleted inserted replaced
18621:b3b241bbbbdb 18622:a306a94111a6
453 */ 453 */
454 @TruffleBoundary 454 @TruffleBoundary
455 @Override 455 @Override
456 public final List<Property> getPropertyList(Pred<Property> filter) { 456 public final List<Property> getPropertyList(Pred<Property> filter) {
457 LinkedList<Property> props = new LinkedList<>(); 457 LinkedList<Property> props = new LinkedList<>();
458 next: for (ShapeImpl current = this; current != getRoot(); current = current.parent) { 458 next: for (Property currentProperty : this.propertyMap.reverseOrderValues()) {
459 Property currentProperty = current.getLastProperty();
460 if (!currentProperty.isHidden() && filter.test(currentProperty)) { 459 if (!currentProperty.isHidden() && filter.test(currentProperty)) {
461 if (currentProperty.getLocation() instanceof DeclaredLocation) { 460 if (currentProperty.getLocation() instanceof DeclaredLocation) {
462 for (Iterator<Property> iter = props.iterator(); iter.hasNext();) { 461 for (Iterator<Property> iter = props.iterator(); iter.hasNext();) {
463 Property other = iter.next(); 462 Property other = iter.next();
464 if (other.isShadow() && other.getKey().equals(currentProperty.getKey())) { 463 if (other.isShadow() && other.getKey().equals(currentProperty.getKey())) {
486 */ 485 */
487 @TruffleBoundary 486 @TruffleBoundary
488 @Override 487 @Override
489 public final List<Property> getPropertyListInternal(boolean ascending) { 488 public final List<Property> getPropertyListInternal(boolean ascending) {
490 LinkedList<Property> props = new LinkedList<>(); 489 LinkedList<Property> props = new LinkedList<>();
491 for (ShapeImpl current = this; current != getRoot(); current = current.parent) { 490 for (Property current : this.propertyMap.reverseOrderValues()) {
492 if (ascending) { 491 if (ascending) {
493 props.addFirst(current.getLastProperty()); 492 props.addFirst(current);
494 } else { 493 } else {
495 props.add(current.getLastProperty()); 494 props.add(current);
496 } 495 }
497 } 496 }
498 return props; 497 return props;
499 } 498 }
500 499
505 */ 504 */
506 @TruffleBoundary 505 @TruffleBoundary
507 @Override 506 @Override
508 public final List<Object> getKeyList(Pred<Property> filter) { 507 public final List<Object> getKeyList(Pred<Property> filter) {
509 LinkedList<Object> keys = new LinkedList<>(); 508 LinkedList<Object> keys = new LinkedList<>();
510 for (ShapeImpl current = this; current != getRoot(); current = current.parent) { 509 for (Property currentProperty : this.propertyMap.reverseOrderValues()) {
511 Property currentProperty = current.getLastProperty();
512 if (!currentProperty.isHidden() && filter.test(currentProperty) && !currentProperty.isShadow()) { 510 if (!currentProperty.isHidden() && filter.test(currentProperty) && !currentProperty.isShadow()) {
513 keys.addFirst(currentProperty.getKey()); 511 keys.addFirst(currentProperty.getKey());
514 } 512 }
515 } 513 }
516 return keys; 514 return keys;