Skip to content

Commit

Permalink
remove redundant holding of number value
Browse files Browse the repository at this point in the history
  • Loading branch information
volker committed Jul 13, 2023
1 parent 1d2d811 commit 5487621
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/main/java/com/inet/sass/parser/LexicalUnitImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class LexicalUnitImpl implements SCSSLexicalUnit, SassListItem {
private int line;
private int column;

private int i;
private float f;
private String sdimension;
private StringInterpolationSequence s;
Expand All @@ -77,13 +76,6 @@ public class LexicalUnitImpl implements SCSSLexicalUnit, SassListItem {
LexicalUnitImpl( String uri, int line, int column, short type, float f ) {
this( uri, line, column, type );
this.f = f;
i = (int) f;
}

LexicalUnitImpl( String uri, int line, int column, short type, int i ) {
this( uri, line, column, type );
this.i = i;
f = i;
}

LexicalUnitImpl( String uri, int line, int column, short type, String sdimension, float f ) {
Expand Down Expand Up @@ -170,12 +162,7 @@ public boolean isNumber() {
}

public int getIntegerValue() {
return i;
}

private void setIntegerValue(int i) {
this.i = i;
f = i;
return (int)f;
}

public float getFloatValue() {
Expand All @@ -200,7 +187,6 @@ public String getFloatOrInteger() {

private void setFloatValue(float f) {
this.f = f;
i = (int) f;
}

public String getDimensionUnitText() {
Expand Down Expand Up @@ -392,9 +378,7 @@ public LexicalUnitImpl modulo(LexicalUnitImpl another) {
if( !checkLexicalUnitType( another, type, SAC_INTEGER, SAC_REAL ) ) {
throw createIncompatibleUnitsException( another );
}
LexicalUnitImpl copy = copy();
copy.setIntegerValue(getIntegerValue() % another.getIntegerValue());
return copy;
return copyWithValue( (int)getIntegerValue() % (int)another.getIntegerValue() );
}

/**
Expand All @@ -406,7 +390,6 @@ public LexicalUnitImpl modulo(LexicalUnitImpl another) {
*/
public LexicalUnitImpl copy() {
LexicalUnitImpl copy = new LexicalUnitImpl( uri, line, column, type );
copy.i = i;
copy.f = f;
copy.s = s;
copy.fname = fname;
Expand Down Expand Up @@ -452,13 +435,10 @@ public static LexicalUnitImpl createInteger( String uri, int line, int column, i
}

public static LexicalUnitImpl createPercentage( String uri, int line, int column, float v ) {
LexicalUnitImpl result = new LexicalUnitImpl( uri, line, column, SAC_PERCENTAGE, v );

if( Math.round( v * 100 * PRECISION ) == (((int)v) * 100 * PRECISION) ) {
result.setIntegerValue( (int)v );
v = (int)v;
}

return result;
return new LexicalUnitImpl( uri, line, column, SAC_PERCENTAGE, v );
}

static LexicalUnitImpl createEMS( String uri, int line, int column, float v ) {
Expand Down

0 comments on commit 5487621

Please sign in to comment.