Skip to content
Snippets Groups Projects
Commit 02c1a7fe authored by Florian Angerer's avatar Florian Angerer
Browse files

Weakened precondition for reusing vectors. Also allow to reuse shared

vectors.
parent 12d67574
No related branches found
No related tags found
No related merge requests found
...@@ -184,11 +184,7 @@ public abstract class CastBaseNode extends CastNode { ...@@ -184,11 +184,7 @@ public abstract class CastBaseNode extends CastNode {
} }
protected boolean isReusable(RAbstractVector v) { protected boolean isReusable(RAbstractVector v) {
// Reusing only of complete vectors otherwise we will produce different warning output return reuseNonShared;
if (reuseNonShared && v.isComplete() && v instanceof RSharingAttributeStorage) {
return !((RSharingAttributeStorage) v).isShared();
}
return false;
} }
protected RAbstractVector castWithReuse(RType targetType, RAbstractVector v, ConditionProfile naProfile) { protected RAbstractVector castWithReuse(RType targetType, RAbstractVector v, ConditionProfile naProfile) {
......
...@@ -71,7 +71,7 @@ abstract class RToComplexVectorClosure extends RToVectorClosure implements RAbst ...@@ -71,7 +71,7 @@ abstract class RToComplexVectorClosure extends RToVectorClosure implements RAbst
@Override @Override
public final RAbstractComplexVector copyWithNewDimensions(int[] newDimensions) { public final RAbstractComplexVector copyWithNewDimensions(int[] newDimensions) {
if (!keepAttributes) { if (keepAttributes) {
return materialize().copyWithNewDimensions(newDimensions); return materialize().copyWithNewDimensions(newDimensions);
} }
return this; return this;
......
...@@ -69,7 +69,7 @@ abstract class RToIntVectorClosure extends RToVectorClosure implements RAbstract ...@@ -69,7 +69,7 @@ abstract class RToIntVectorClosure extends RToVectorClosure implements RAbstract
@Override @Override
public final RAbstractIntVector copyWithNewDimensions(int[] newDimensions) { public final RAbstractIntVector copyWithNewDimensions(int[] newDimensions) {
if (!keepAttributes) { if (keepAttributes) {
return materialize().copyWithNewDimensions(newDimensions); return materialize().copyWithNewDimensions(newDimensions);
} }
return this; return this;
...@@ -103,6 +103,7 @@ final class RLogicalToIntVectorClosure extends RToIntVectorClosure implements RA ...@@ -103,6 +103,7 @@ final class RLogicalToIntVectorClosure extends RToIntVectorClosure implements RA
final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAbstractIntVector { final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAbstractIntVector {
private final RDoubleVector vector; private final RDoubleVector vector;
private boolean naReported;
RDoubleToIntVectorClosure(RDoubleVector vector, boolean keepAttributes) { RDoubleToIntVectorClosure(RDoubleVector vector, boolean keepAttributes) {
super(keepAttributes); super(keepAttributes);
...@@ -122,7 +123,10 @@ final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAb ...@@ -122,7 +123,10 @@ final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAb
} }
int result = (int) value; int result = (int) value;
if (result == Integer.MIN_VALUE || value > Integer.MAX_VALUE) { if (result == Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
RError.warning(RError.SHOW_CALLER2, RError.Message.NA_INTRODUCED_COERCION); if (!naReported) {
RError.warning(RError.SHOW_CALLER2, RError.Message.NA_INTRODUCED_COERCION);
naReported = true;
}
return RRuntime.INT_NA; return RRuntime.INT_NA;
} }
return result; return result;
...@@ -132,6 +136,7 @@ final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAb ...@@ -132,6 +136,7 @@ final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAb
final class RDoubleSequenceToIntVectorClosure extends RToIntVectorClosure implements RAbstractIntVector { final class RDoubleSequenceToIntVectorClosure extends RToIntVectorClosure implements RAbstractIntVector {
private final RDoubleSequence vector; private final RDoubleSequence vector;
private boolean naReported;
RDoubleSequenceToIntVectorClosure(RDoubleSequence vector, boolean keepAttributes) { RDoubleSequenceToIntVectorClosure(RDoubleSequence vector, boolean keepAttributes) {
super(keepAttributes); super(keepAttributes);
...@@ -151,7 +156,10 @@ final class RDoubleSequenceToIntVectorClosure extends RToIntVectorClosure implem ...@@ -151,7 +156,10 @@ final class RDoubleSequenceToIntVectorClosure extends RToIntVectorClosure implem
} }
int result = (int) value; int result = (int) value;
if (result == Integer.MIN_VALUE || value > Integer.MAX_VALUE) { if (result == Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
RError.warning(RError.SHOW_CALLER2, RError.Message.NA_INTRODUCED_COERCION); if (!naReported) {
RError.warning(RError.SHOW_CALLER2, RError.Message.NA_INTRODUCED_COERCION);
naReported = true;
}
return RRuntime.INT_NA; return RRuntime.INT_NA;
} }
return result; return result;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment