Forum > FPC development

[SOLVED] Improvement of TBinaryObjectWriter.WriteIdent

<< < (2/2)

lagprogramming:

--- Quote from: Josh on June 22, 2023, 10:50:11 am ---for readability curious as to why your removing the comment.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ----  { Check if Ident is a special identifier before trying to just write-    Ident directly }
--- End quote ---

When I removed it I was thinking that the comment makes sense only in the presence of the if then else series, not in the presence of a case statement. The presence of the case statement would imply the contents of the existing comment because that's how the case statements work.

Josh:
I find the purpose of the comment is to explain what the following code does; without having to analyze the code to work out what its doing.

Thaddy:
The case statement with strings is actually translated by the compiler into if then else.
Also note the introductary notes about this "feature". Any way you see it, case with string introduces an indirection.
There was quite a discussion on the development forum about this too.

AlexTP:
Posted to https://gitlab.com/freepascal.org/fpc/source/-/issues/40334

Stefan Glienke:
Anyone who fancies compiler optimization might want to look into switch lowering - see https://www.youtube.com/watch?v=gMqSinyL8uk

Navigation

[0] Message Index

[*] Previous page

Go to full version