- abbeyj parentYou have a typo in there. You want https://www.google.com/search?q=%2810%5E100%29%2B1-%2810%5E1... . Google also gets the "wrong answer" for this expression, 0 instead of 1.
- The page is 404 now. It looks like something went wrong when the author was trying to push a small edit to the page. The content is viewable at https://github.com/hiAndrewQuinn/til/blob/main/copy-item-is-...
- > We all know that strlen will return 5, but some compilers don't: https://godbolt.org/z/M7x5qraE6
I feel like it is unfair to blame the compiler when you've explicitly asked for `/O1`. If you change this to `/O2` or `/Ox` then MSVC will optimize this into a constant 5, proving that it does "know" that strlen will return 5 in this case.
- If you want to tell the compiler not to worry about the possible buffer overrun then you can try `int foo(char const s[static 4])`. Or use `&` instead of `&&` to ensure that there is no short-circuiting, e.g. `if ((s[0] == 'h') & (s[1] == 'e') & (s[2] == 'l') & (s[3] == 'l'))` Either way, this then compiles down to a single 32-bit comparison.
Interestingly, it is comparing against a different 32-bit value than `bar` does. I think this is because you accidentally got the order backwards in `bar`.
The code in `bar` is probably not a good idea on targets that don't like unaligned loads.
- Are you thinking of https://web.archive.org/web/19990508050925/http://support.mi... ? Or was there a different bug in NT 4?
- I tried to reproduce this binary to see what the 278 KB was being taken up by. The first obstacle that I ran into was that the build.bat file doesn't work if you have git configured to use core.autocrlf=false. Changing that to core.autocrlf=true and recloning was sufficient to get me building.
I'm using x86_64-15.1.0-release-win32-seh-msvcrt-rt_v12-rev0.7z from https://github.com/niXman/mingw-builds-binaries/releases/tag... as the toolchain. This produces a 102 KB .exe file. Right off the bat we are doing much better than the claimed 278 KB. Maybe the author is using a different toolchain or different settings? Exact steps to reproduce would be welcome.
We can improve this by passing some switches to GCC.
If all you are interested in is a small .exe size, there is plenty of room for improvement here.gcc -Os => 100 KB gcc -Oz => 99 KB gcc -flto => 101 KB gcc -s => 51 KB gcc -s -Oz -flto => 47 KB - It seems like it should be possible to factor out most of the iterator boilerplate into a helper class. Then each place where you want to iterate you can construct an instance of that helper class and supply a lambda that specifies how to descend into children. If you're doing the same iteration in several places then you can use a named function instead of a lambda, which means less typing for each `for` loop. Here's a rough sketch: https://godbolt.org/z/x94WY77rv
- 2 points
- 12 points
- I built a browser-based version that allows you to rotate it: http://www.stardrifter.org/regexp/
- > The student dutifully changed the line, and both tools reported their satisfaction with the replacement
clang-tidy's `modernize-use-emplace` check warns for both the original version that uses `push_back` (as quoted in the article) and for the modified version that uses `emplace_back`:
https://godbolt.org/z/sE7jWacTfwarning: unnecessary temporary object created while calling emplace_back [modernize-use-emplace] 13 | widgets.emplace_back(Widget(foo, bar, baz)); | ^~~~~~~ ~It appears that this check was improved to add this warning at some point between clang v14 and now. At least things have improved since the article was written.
- This is how Dalvik (the old Android Java interpreter) worked, with 64 chosen as the size of an instruction handler. See https://wladimir-tm4pda.github.io/porting/dalvik.html (search for "computed goto").
- > Line 3000 starts with REM, short for “remark”. We call them “comments” these days, but the ZX Spectrum is British, the brainchild of mad genius Sir Clive Sinclair.
I'm not sure, but is this statement implying that `REM` is a British invention? The original Darthmouth BASIC had a REM statement. https://en.wikipedia.org/wiki/Dartmouth_BASIC#First_Edition
- This isn't really about using Explorer for file management. It is about using Explorer as the shell. That's the default setup for everybody. Changing the default steel is difficult and some programs may not be compatible with whatever alternative shell you switch to.
Most people don't want to learn a whole new shell. They just want the Explorer shell to have the features that it has had since Windows 7. Features that Microsoft inexplicably chose to remove in Windows 11 and that they are only now belatedly adding back.
- Since you're stuck using active FTP, maybe using nf_conntrack_ftp would help? I believe it is supposed to snoop the FTP connection, extract the port number from the PORT command, and then open only that port (from only that one IP) on the firewall. Of course since this is all on your LAN, just opening up all connections from the IP address is not really that dangerous and so anything more advanced might not be worth the effort.
- The FTP connection seems to be using active mode (PORT command). Does using passive mode (PASV command) help at all? This is usually the easiest fix for problems with FTP and firewalls, without having to reconfigure or poke holes in the firewall. I actually thought that most ftp clients had switched to passive mode by default to avoid this type of issue.
- I think this is now fixed (or worked around) by https://github.com/easylist/easylist/issues/17937 ?
- > Each time the [std::deque] slides, every value in the queue has to change position in memory
I don't think that this is true. `std::deque` has guaranteed O(1) complexity for insertions or deletions at the beginning or end of the container. It couldn't provide this if it was moving every value in the queue.
> How do we alter the stackSum when the queue moves?
You never quite answer this question. How are `sumOut` and `sumIn` related to `stackSum`? This is available in the code but I feel like there should at least be a one-line summary available without having to click through to the code.
> sumOut is what we need to add to the stack.
This is supposed to be `sumIn`?
The examples that you provide use a radius of 2, thus having a `sizeOfStack` of (radius+1)*2 = 9 and requiring a division by 9 for each pixel. Have you considered using a radius of 1 or a radius of 3 instead? This would require division by (1+1)*2 = 4 or (3+1)*2 = 16 respectively which could then be done with a bitshift instead of a division. You'd have to template the code on `radius` instead of passing it in as a runtime parameter so that the compiler could lower the divisions to bitshifts.
- I was sure this was going to link to this image: https://imgur.com/zh4F55R
- 2 points
- There are literals that create composite types, since C99: https://en.cppreference.com/w/c/language/compound_literal