NewPipeExtractor
NewPipeExtractor copied to clipboard
Why does EMPTY_STRING exist?
This is a followup to my joke PR #825. The reason I made that PR was to emphasize the fact that storing "" in a constant variable and then using that variable throughout the code is imo completely pointless.
- If we are doing this for optimization purposes -> we are not optimizing anything. JVM already does this for us: https://www.tutorialspoint.com/how-and-where-does-string-literals-in-java-stored-in-the-memory.
- If we are doing this for clarity -> I personally find
""clearer, more standard and more recognizable thanEMPTY_STRINGthat sometimes could also appear asUtils.EMPTY_STRINGand from a first look looks like a non-empty constant string.""can be considered a constant for which no name is needed, just like0(while it would be a good idea to give a name to the various-1scattered about in the extractor), and anyway the nameEMPTY_STRINGdoesn't give any more information than just"". - Importing
EMPTY_STRINGin all files increases the bytecode size (though this would really be just a minor problem)
I can only find downsides for EMPTY_STRING to exist and I would therefore remove it completely.
Note: This was introduced with https://github.com/TeamNewPipe/NewPipeExtractor/pull/287 / https://github.com/TeamNewPipe/NewPipeExtractor/commit/00d1ed439b49cdbabcd6933afd7945bc45e9aefc#diff-8fd4eab23bfbb031a3e5af338eb2e9814c1a7fcef5862a192566dfed8ccb474e
I'm also in favor of removing it.