Closed rlnt closed 1 year ago
The sanitizing was initially applied to all possible elements but this obviously drastically increased load times. I did some benchmarking on the dev version of Enigmatica 9 with EE. Here are the results.
Old version (no implicit count checks): 8.853ms
New version (sanitized every element): 18.330ms
With basic type filter: 17.273ms
if (firstElem.getClass() == secondElem.getClass() || (firstElem instanceof JsonPrimitive && secondElem instanceof JsonObject) || (firstElem instanceof JsonObject && secondElem instanceof JsonPrimitive)) { firstElem = sanitize(firstElem); secondElem = sanitize(secondElem); }
With basic type filter and array length checks: 17.068ms
if ((firstElem instanceof JsonArray firstArray && secondElem instanceof JsonArray secondArray && firstArray.size() == secondArray.size()) || firstElem.getClass() == secondElem.getClass() || (firstElem instanceof JsonPrimitive && secondElem instanceof JsonObject) || (firstElem instanceof JsonObject && secondElem instanceof JsonPrimitive)) { firstElem = sanitize(firstElem); secondElem = sanitize(secondElem); }
With type filter, array length checks and without primitives: 14.593ms
if ((firstElem instanceof JsonArray firstArray && secondElem instanceof JsonArray secondArray && firstArray.size() == secondArray.size()) || (firstElem instanceof JsonObject && secondElem instanceof JsonObject) || (firstElem instanceof JsonPrimitive && secondElem instanceof JsonObject) || (firstElem instanceof JsonObject && secondElem instanceof JsonPrimitive)) { firstElem = sanitize(firstElem); secondElem = sanitize(secondElem); }
The last method has an insanely ugly condition but it's only 5.740ms slower than the version without any sanitizing and implicit count checks at all.
The sanitizing was initially applied to all possible elements but this obviously drastically increased load times. I did some benchmarking on the dev version of Enigmatica 9 with EE. Here are the results.
Old version (no implicit count checks): 8.853ms
New version (sanitized every element): 18.330ms
With basic type filter: 17.273ms
With basic type filter and array length checks: 17.068ms
With type filter, array length checks and without primitives: 14.593ms
The last method has an insanely ugly condition but it's only 5.740ms slower than the version without any sanitizing and implicit count checks at all.