Jack Simms did an amazing talk about talking. In the middle, they also re-did a mini talk. All of it was SO good.
4.4.2025 12:44Jack Simms did an amazing talk about talking. In the middle, they also re-did a mini talk. All of it was SO good.#accuconf@anthonywilliams
Great talk, thank you.
Last night at #accuconf was great.
- Did a lightning talk ⚡️
- Went climbing with some other attendees 🧗
- Drinks and chatting with other attendees 🍻
Have you ever been working on part of a system which, taken in isolation, looks completely insane?
#programming #AccuConf #AccuConf2025
30.3.2025 17:03Have you ever been working on part of a system which, taken in isolation, looks completely insane?#programming #AccuConf #AccuConf2025I have no idea what coach I'm in. I have no idea how to find my seat.
30.3.2025 10:23I have no idea what coach I'm in. I have no idea how to find my seat.Travel to #accuconf looking good so far (sarcasm)
**grumble grumble trains something grumble grumble**
30.3.2025 09:56Travel to #accuconf looking good so far (sarcasm)**grumble grumble trains something grumble grumble**A solution
This is my solution:
https://godbolt.org/z/hMxzhd6fT
C++ hint 10
`std::string::iterator` is more or less the same as `char *`, so for performance you need to be aware of the strict aliasing rule.
Basically any write to a `char *` would invalidate any assumptions read being invariant between loop iterations. Hence a read in a loop that you know doesn't change, and you maybe assumed to be optimised to read once, that assumption is wrong. The compiler can't assume that and would have to read on every iteration.
29.3.2025 21:40C++ hint 10`std::string::iterator` is more or less the same as `char *`, so for performance you need to be aware of the strict aliasing...C++ hint 9
Did you spell out the whole type `std::string::iterator`?
Try using `auto`
29.3.2025 19:13C++ hint 9Did you spell out the whole type `std::string::iterator`?Try using `auto`Code design hint 1
Did you optimize for a particular case?
If so why? Is it expected that the string would be empty or have only one word?
29.3.2025 19:11Code design hint 1Did you optimize for a particular case?If so why? Is it expected that the string would be empty or have only one word?C++ hint 8
This is just a style choice. Not good or bad.
Have you tried std::begin(str), std::end(str), std::next(it), rather than str.begin(), str.end(), it+1
What about if you use ADL so that you don't need to have the std namespace?
29.3.2025 19:09C++ hint 8This is just a style choice. Not good or bad.Have you tried std::begin(str), std::end(str), std::next(it), rather than...C++ hint 7
Do variables have good names?
Is there a duality between a pair of variables? If so are they named consistently?
29.3.2025 19:06C++ hint 7Do variables have good names?Is there a duality between a pair of variables? If so are they named consistently?C++ hint 6
Have you put `const` on everything you can?
29.3.2025 19:04C++ hint 6Have you put `const` on everything you can?C++ hint 5
Are you testing a very similar condition twice in a hot loop?
Try an infinite loop and put the test and break only at the point you require.
29.3.2025 19:04C++ hint 5Are you testing a very similar condition twice in a hot loop?Try an infinite loop and put the test and break only at the point you...C++ hint 4
Did you use std::isspace?
That maybe too heavy weight.
It is a call to a C function, so not inline-able (bad for performance). Also would return true for stuff that wasn't a space character.
29.3.2025 19:01C++ hint 4Did you use std::isspace?That maybe too heavy weight.It is a call to a C function, so not inline-able (bad for performance). Also...C++ hint 3
Did you use any std::string::find* methods? And have to deal with std::string::npos? This is practically same as using indices.
Maybe better to just use iterators.
29.3.2025 18:58C++ hint 3Did you use any std::string::find* methods? And have to deal with std::string::npos? This is practically same as using indices....C++ hint 2
Did you extract anything into a function?
Did you give it a good name?
Have a look in `#include <algorithm>` does it already exist?
https://en.cppreference.com/w/cpp/algorithm
29.3.2025 18:55C++ hint 2Did you extract anything into a function?Did you give it a good name?Have a look in `#include <algorithm>` does it already...C++ hint 1
Are you using indices?
e.g. str[i]
Did you have random +1 or -1 modifiers to get to correct index? Or even worse +2 or -2?
Try using iterators and think about leaning into the idea of half open interval
auto b = str.begin();
auto e = str.end();
The half open interval for the string being [b, e)
29.3.2025 18:30C++ hint 1Are you using indices?e.g. str[i]Did you have random +1 or -1 modifiers to get to correct index? Or even worse +2 or -2?Try using...Algorithm hint 2
This exercise is not about if can you imagine the smart/best algorithm. The image shows the approach to do it in O(n) time, O(1) space.
Now go write good C++
29.3.2025 18:25Algorithm hint 2This exercise is not about if can you imagine the smart/best algorithm. The image shows the approach to do it in O(n) time,...Algorithm hint 1
This can be done in O(n) time and O(1) space
29.3.2025 18:19Algorithm hint 1This can be done in O(n) time and O(1) space⬆️
⬇️