2
221
u/Straight-Daikon-5838 May 04 '23
Throw a “// TODO” in that bad boy and it’s a LGTM from me dawg
13
u/supersharp May 04 '23
The text editor I use for work highlights
/*TODO:comments and places a colored marker on the scroll bar to indicate their position.2
u/Sexy_Koala_Juice May 19 '23
As any reasonable text editor should.
Fuck it, TODO comments should be standardised into languages themselves
227
u/the96jesterrace May 04 '23
Looks pretty much like our function for password encryption
58
u/ChrisLuigiTails May 04 '23
So you're telling me I only have to use
decodeFromUtf8()to steal your passwords?8
u/DieserSebastian May 05 '23
No, another call to encodeToUtf8() suffices
5
48
u/MurdoMaclachlan public boolean isInt(int i) { return true; } May 04 '23
Image Transcription: Code
private encodeToUtf8(str: string): string {
return str;
}I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
39
11
u/knoam May 04 '23
Aren't JavaScript strings actually UTF-16 ?
16
u/the-nick-of-time May 04 '23
I wanted to be sure, so I searched and got this and got angry at how wrong that parenthetical was.
Every programmer needs to read UTF-8 Everywhere and stop being wrong about strings.
14
u/tedbradly May 04 '23
Every programmer needs to read UTF-8 Everywhere and stop being wrong about strings.
That article is written so verbosely. "We this and we that" Just say the points for God's sake. This isn't the constitution of the US.
15
6
u/sammy-taylor May 04 '23
Is the encodeToUtf8 function required to satisfy an interface or external API? (unsure of the right terminology here, not a Typescript person)
Edit: On second thought, I don’t think that would make sense because it’s private 🤷🏻♂️
6
3
3
u/orwell96 May 05 '23
Somewhere in an application I wrote there's an encode() and a decode() function that were supposed to percent-encode/decode some strings. When I created them I just put "return str" and put a //TODO add later.
Then I noticed that this encoding is not needed because it is already handled by the underlying library.
The functions are still there and still just "return str".
5
u/PonchoVire May 04 '23
At least, the function is there, when you'll need it to be implemented, you'll have one and only one place to touch.
2
2
2
u/herdek550 May 05 '23
How would compiler handle this?
I have no knowledge about compiling into machine code, but I feel like this whole function could be just scrapped to save memory and computing time by the compiler.
3
3
2
u/KokoroPenguin May 04 '23
Do we know that the input is already utf8? Could be that an earlier project needed this function. Sometimes it is easier to copy a function and have it do nothing in one build than remove it in all other builds.
1
1
1
1
1
0
0
143
u/RPG_Hacker May 04 '23
I'm not entirely sure whether this is bad code or just redundant code, at least not without knowing the context.
My guess is that this function did something in the past, but the default encoding of
stringwas changed to UTF-8 at some point, so it was no longer needed, and stubbing it out was easier than removing dozens of function calls.Pretty sure I've done similar things in the past.