Don’t spend more than a few seconds trying to understand it. Simply add a code review comment saying, “It’s hard for me to understand this piece of code,” or be more specific, and say, “Please use more descriptive names here.”
The developer then clarifies the code and sends it to you for review again:
Now we can read it pretty easily, which is a benefit in itself.
Often, just asking a developer to clarify a piece of code will result in fundamental improvements. In this case, the developer noticed possible performance improvements since the code was easier to read—the function now returns earlier when the number isn’t prime, and the loop only goes to n/2 instead of n.
However, now that we can easily understand this code, we can see many problems with it. For example, it has strange behavior with 0 and 1, and there are other problems, too. But most importantly, it is now apparent that this entire function should be removed and be replaced with a preexisting function for detecting if a number is prime. Clarifying the code helped both the developer and reviewer.
In summary, don’t waste time reviewing code that is hard to understand, just ask for it to be clarified. In fact, such review comments are one of the most useful and important tools a code reviewer has!