Гениальное ускорение кода
uint64_t faster_sum(Node* node) { uint64_t value = 0; Node* next = NULL; while (node) { value += node->value; next = node->next; // Guess the next value node++; // But fix it up if we guessed wrong ( // next to each other). if (node != next) { node = next; } } return value; }
На изображении показан фрагмент кода на C/C++, который суммирует значения связного списка. Вместо перехода по указателю next код сначала угадывает следующий адрес с помощью node++, а затем исправляет ошибку; шутка в абсурдном представлении спекуляции процессора как намеренно написанного «гениального» кода. Такой мем отправляют в ответ на чрезмерно умные, сомнительные или неоправданно оптимизированные решения. EN: The image shows a C/C++ code fragment that sums the values of a linked list. Instead of following the next pointer directly, the code first guesses the next address using node++ and then fixes the mistake; the joke is the absurd presentation of processor speculation as intentionally written “genius” code. This meme is sent in response to overly clever, questionable, or unjustifiably optimized solutions.
- @ithueti / 17750 2026-03-01
- Type
- image
- Size
- 800×705 · 62.6 KiB
- Mood
- саркастичный, абсурдный
- Language
- en
- Added