dat-encoding
dat-encoding copied to clipboard
Extracting validation logic to prevent unnecessary double processing
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.
this is for perf, right? If so, I'm curious where it's used in a perf relevant way
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.