dat-encoding icon indicating copy to clipboard operation
dat-encoding copied to clipboard

Extracting validation logic to prevent unnecessary double processing

Open martinheidegger opened this issue 7 years ago • 2 comments

Currently in case a string is passed-in to encode or a Buffer is passed-in to decode it will do an additional en/decoding step. This PR prevents the unnecessary creation of intermediate Strings/Buffers by extracting the validation logic into own functions.

martinheidegger avatar Apr 12 '18 16:04 martinheidegger

this is for perf, right? If so, I'm curious where it's used in a perf relevant way

juliangruber avatar Apr 15 '18 11:04 juliangruber

I was looking through the code in dat-desktop. At every operation it called encode as a way to validate if the api parameter was correct (even though it was usually just the already verified & cleaned input). Seemed like a unnecessary effort to be taken at every operation.

martinheidegger avatar Apr 15 '18 16:04 martinheidegger