Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 12/13/24 in all areas

  1. sjordi

    Screen Brightness in iOS

    Of course the app had something else: images with a kid saying to shush with his finger on his mouth, the moon, the sun to explain a toddler what time of day it is. Actually, the brightness was just controlling the background to dim the screen at night. Could make it a bit more configurable and actually have it in the AppStore for others. Was intended as a sleep trainer like the image here: eyes closed you keep sleeping, eyes open, you can disturb us.
  2. JohnLM

    The Advent of Code 2024.

    @corneliusdavid, ah, now I understand, since I am not a member of AoC, nor registered participant. I am an outsider just playing along as best I can. Also, I found this website: https://jeroenheijmans.github.io/advent-of-code-surveys/ I did not see any Delphi / Pascal language mentioned. Looks like there are very few people (including myself--day1 and 2 puzzles solved) in this language tackling AoC.
  3. corneliusdavid

    The Advent of Code 2024.

    Many people post their code solutions on Github to share and discuss with others; some include everything, even the input files and the instructions for the puzzle. This was a reminder on the Reddit site (where a lot of solutions are posted) not to include the instructions and input data. There are several different sets of input files and they generate different numbers; you're not supposed to share the input file generated for your unique login to AoC. When you submit a correct answer to the first puzzle for a particular day, you get revealed a second puzzle for that day (there are only two per day). You don't see it until you correctly answer the first part--and the second one is always some twist to the first puzzle and uses the same input file. If you don't see any of them, then you haven't submitted any correct answers. You don't have to be at the website at a particular time but they aren't revealed ahead of the day for the puzzle.
  4. Brian Evans

    What is this flashing message doing there?

    The Snipping Tool in Windows 11 does video in addition to static screen grabs. After triggering (SHIFT+Win+S) make sure video is selected, select the screen region you want to record then start recording.
  5. dummzeuch

    Refactor rename field fails always

    But MMX works differently. It does not really analyze the code but replaces all matching strings within a given scope (e.g. a procedure) rather than identifiers. That's why it can optionally even replace identifiers mentioned in comments. But it can also replace strings that are not the intended identifier.
  6. Lajos Juhász

    Why doesn't this work?

    procedure TForm1.FormCreate(Sender: TObject); begin Var Boy: string; Girl: string; Couple: string; end; For those who doesn't have a modern compiler. Of course inline var is not a block thus it will produce errors: [dcc32 Error] Unit1.pas(29): E2003 Undeclared identifier: 'Girl' [dcc32 Error] Unit1.pas(29): E2029 '(' expected but ';' found [dcc32 Error] Unit1.pas(30): E2003 Undeclared identifier: 'Couple' [dcc32 Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas' Failed
  7. Uwe Raabe

    Why doesn't this work?

    You are using inline variables. Try moving the variables declaration before the begin. procedure TFormStringConcatenation.ButtonAddCoupleClick(Sender: TObject); Var Boy: string; Girl: string; Couple: string; begin Boy := EditEnterBoy.Text; Girl := EditEnterGirl.Text; Couple := Boy + ' and ' + Girl; ListBoxCouple.Items.Add(Couple);
  8. Roger Cigol

    What is this flashing message doing there?

    I think this sounds like the "auto complete" calculating what to allow you to enter as part of the code. This was a bit flakey on some of the recent versions but works quite well on 12.2
  9. corneliusdavid

    The Red Arrow

    It's Flow Control Highlighting. It indicates that execution flow leaves the block or function at that point. In this case, it's not terribly useful as the "return" statement is at the end of the function but if you had a switch statement with several cases and some of them returned from the function, those flow-control markers would give a visual cue about where the code goes. You control this in Tools > Options > Editor > Color > Structural Highlighting.
  10. Stefan Glienke

    Micro optimization: IN vs OR vs CASE

    The point that others already have expressed is that despite being interested in a topic as performance improvement so low level (as in instruction-level instead of algorithmic level) you seem to lack some important knowledge to do so such as assembly - it does not require as much as it does to write assembly code but to understand it in order to be able to look at the code in the debugger and see that some comparisons are apples and bananas. I did not even read through your code but simply placed a breakpoint into your IsIN function and noticed that it contained a function call to System.SetElem (that even was the first time I have ever seen that function being called so a TIL for me). Why was that the case? Because you are not using consts here but variables. Had you simply made consts for all those IDs the code would have almost as fast as the IsOR which does not suffer to extra function calls but from memory reads (not noticeable in the benchmark because its all in L1 cache already). On my CPU InOR is still a little faster than IsIN which is due to the fact how the compiler builds the in - you can see that for yourself in the disassembly and then look at instruction timings, read up on macro-operation fusion and data dependency For reference, this is the assembly for the two functions when using consts Project1.dpr.40: Result := aID in [xControlsRec.ButtonID, xControlsRec.FormID, xControlsRec.ListBoxID, xControlsRec.TabControlID, xControlsRec.ComboBoxID]; 004CEE7C 83E802 sub eax,$02 004CEE7F 7417 jz $004cee98 004CEE81 83E802 sub eax,$02 004CEE84 7412 jz $004cee98 004CEE86 83E802 sub eax,$02 004CEE89 740D jz $004cee98 004CEE8B 83E802 sub eax,$02 004CEE8E 7408 jz $004cee98 004CEE90 83E802 sub eax,$02 004CEE93 7403 jz $004cee98 004CEE95 33C0 xor eax,eax 004CEE97 C3 ret 004CEE98 B001 mov al,$01 Project1.dpr.41: end; 004CEE9A C3 ret 004CEE9B 90 nop Project1.dpr.45: Result := (aID = xControlsRec.ButtonID) or (aID = xControlsRec.FormID) or (aID = xControlsRec.ListBoxID) or (aID = xControlsRec.TabControlID) or (aID = xControlsRec.ComboBoxID); 004CEE9C 83F802 cmp eax,$02 004CEE9F 7417 jz $004ceeb8 004CEEA1 83F804 cmp eax,$04 004CEEA4 7412 jz $004ceeb8 004CEEA6 83F806 cmp eax,$06 004CEEA9 740D jz $004ceeb8 004CEEAB 83F808 cmp eax,$08 004CEEAE 7408 jz $004ceeb8 004CEEB0 83F80A cmp eax,$0a 004CEEB3 7403 jz $004ceeb8 004CEEB5 33C0 xor eax,eax 004CEEB7 C3 ret 004CEEB8 B001 mov al,$01 Project1.dpr.46: end; 004CEEBA C3 ret Depending on the number of IDs you have it might be worth using power of two and bitmasks or an enum directly because that would only require one cmp/test making the function twice as fast and perfect for inlining which would then also eliminate the function call overhead at all.
×