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 {
}
protected boolean isReusable(RAbstractVector v) {
// Reusing only of complete vectors otherwise we will produce different warning output
if (reuseNonShared && v.isComplete() && v instanceof RSharingAttributeStorage) {
return !((RSharingAttributeStorage) v).isShared();
}
return false;
return reuseNonShared;
}
protected RAbstractVector castWithReuse(RType targetType, RAbstractVector v, ConditionProfile naProfile) {
......
......@@ -71,7 +71,7 @@ abstract class RToComplexVectorClosure extends RToVectorClosure implements RAbst
@Override
public final RAbstractComplexVector copyWithNewDimensions(int[] newDimensions) {
if (!keepAttributes) {
if (keepAttributes) {
return materialize().copyWithNewDimensions(newDimensions);
}
return this;
......
......@@ -69,7 +69,7 @@ abstract class RToIntVectorClosure extends RToVectorClosure implements RAbstract
@Override
public final RAbstractIntVector copyWithNewDimensions(int[] newDimensions) {
if (!keepAttributes) {
if (keepAttributes) {
return materialize().copyWithNewDimensions(newDimensions);
}
return this;
......@@ -103,6 +103,7 @@ final class RLogicalToIntVectorClosure extends RToIntVectorClosure implements RA
final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAbstractIntVector {
private final RDoubleVector vector;
private boolean naReported;
RDoubleToIntVectorClosure(RDoubleVector vector, boolean keepAttributes) {
super(keepAttributes);
......@@ -122,7 +123,10 @@ final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAb
}
int result = (int) 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 result;
......@@ -132,6 +136,7 @@ final class RDoubleToIntVectorClosure extends RToIntVectorClosure implements RAb
final class RDoubleSequenceToIntVectorClosure extends RToIntVectorClosure implements RAbstractIntVector {
private final RDoubleSequence vector;
private boolean naReported;
RDoubleSequenceToIntVectorClosure(RDoubleSequence vector, boolean keepAttributes) {
super(keepAttributes);
......@@ -151,7 +156,10 @@ final class RDoubleSequenceToIntVectorClosure extends RToIntVectorClosure implem
}
int result = (int) 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 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