Simplify the "is integer" checks in CFFCompiler.encodeNumber
The `isNaN` check is obviously redundant, since `NaN` is the only value that isn't equal to itself; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN#Examples The `parseFloat`/`parseInt` comparison would make sense if the `value` ever contains a String, which however is never actually the case. Besides looking through the code, I've also run the entire test-suite locally with `assert(typeof value === "number", "encodeNumber");` added at the top of the method and there were no failures. Hence we can simplify the "is integer" check a bit in the `CFFCompiler.encodeNumber` method.
This commit is contained in:
parent
a91f24cda9
commit
517d92a121
@ -1483,8 +1483,7 @@ var CFFCompiler = (function CFFCompilerClosure() {
|
||||
return output.data;
|
||||
},
|
||||
encodeNumber: function CFFCompiler_encodeNumber(value) {
|
||||
if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
|
||||
// isInt
|
||||
if (Number.isInteger(value)) {
|
||||
return this.encodeInteger(value);
|
||||
}
|
||||
return this.encodeFloat(value);
|
||||
|
Loading…
Reference in New Issue
Block a user