3,068 karma · joined May 29, 2013
My email in base64: Y29kZXJzdGV2ZUBsaXNwLnNwYWNlCg==
Just copying someone else's solution, or getting an LLM to fix it for you will be very low struggle, so you won't learn much.
To add some struggle, maybe look up a solution in a different language and translate to your language? You could choose a solution in a language similar to your language, so if you are solving in C, perhaps look up a C# solution or to make it harder look up a solution in a different paradigm. Find a Haskell solution or a Prolog one and see if that gives you enough hints.
My usage of pin essentially comes down to "I try something, and the compiler complains at me, so I pin stuff and then it compiles."
It's never been such a hurdle in the day to day coding I need to do that I've been forced to sit down and truly grok it.
I never worked out how that could be happening.
If that function was taking a reference to an object that was fairly expensive to create a default value for then my conundrum would still exist.
pub fn encrypted(&self) -> Vec<u8> {
encrypt(self.payload.as_ref().unwrap_or(&vec![]))
}
Needlessly allocates a `Vec` if `self.payload` is `Some`. Really you should do: encrypt(&self.payload.as_ref().unwrap_or_else(|| &vec![]))
But that isn't going to work because the `else` Vec will be dropped at the end of the closure.In this situation (if the code was on a hot path where every bit of performance mattered) I would probably do something like:
match self.payload.as_ref() {
Some(payload) => encrypt(payload),
None => encrypt(&vec![])
}
There is a slight bit of duplicated code. I'd be curious if anyone could come up with a better way.It is a scaling issue. Your browser may not blink at loading 100 resources, but say you were constantly reloading 100s of tabs, it would start to grind down. Rewriting in a more efficient language would help, but that would just mean it would start to grind down when you have 20,000 users rather than 10,000.
I'm surprised it doesn't do some kind of batching peer to peer communication instead. Maybe that wouldn't be as real time.
Thanks for the insight.
Like, are the certain design decisions that could be optimised to make it more resource efficient? Is it just because it is written in Ruby? Is there something inherent to ActivityPub that means it has to use a lot of resources? Can work be done to make it cheaper to run?
Learn to use multiple cursors in Helix - many of the things I have found lacking from Vi - eg pressing . doesn't work the same way in Helix - can be made up with more or less by using multiple cursors.