git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/4] t-reftable-readwrite: use 'for' in place of infinite 'while' loops

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 9, 2024, 19:06 UTC
Message-ID
<xmqqfrrdcy84.fsf@gitster.g>
In-Reply-To
<20240809111312.4401-4-chandrapratap3519@gmail.com>
Chandra Pratap <chandrapratap3519@gmail.com> writes:
> Using a for loop with an empty conditional statement is more concise
> and easier to read than an infinite 'while' loop in instances
> where we need a loop variable. Hence, replace such instances of a
> 'while' loop with the equivalent 'for' loop.

Quite honestly, the above is counter-productive if pushed as a general guideline, because the goodness of it depends what happens in the third part of the for () control (i.e., what should happen at the end of each iteration and if it wants to be bypassed in the conditional inside the loop).

In this particular case, it probably is OK, but still is a subjective, borderline Meh, to me.

I see no violation of correctness in the rewrite, though ;-)
Previous: Chandra PratapNext: Chandra Pratap
Message 20 of 30 in “t: port reftable/readwrite_test.c to the unit testing framework”
  1. Chandra PratapAug 7, 2024
  2. 1/5 t: move reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 7, 2024
  3. 2/5 t-reftable-readwrite: use free_names() instead of a for loopChandra Pratap, Aug 7, 2024
  4. 3/5 t-reftable-readwrite: use 'for' in place of infinite 'while' loopsChandra Pratap, Aug 7, 2024
  5. 4/5 t-reftable-readwrite: add test for known errorChandra Pratap, Aug 7, 2024
  6. 5/5 t-reftable-readwrite: add tests for print functionsChandra Pratap, Aug 7, 2024
  7. Patrick SteinhardtAug 8, 2024
  8. Patrick SteinhardtAug 8, 2024
  9. Chandra PratapAug 8, 2024
  10. Junio C HamanoAug 9, 2024
  11. [GSoC][PATCH v2 0/4] t: port reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 9, 2024
  12. 1/4 t: move reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 9, 2024
  13. Junio C HamanoAug 9, 2024
  14. Chandra PratapAug 12, 2024
  15. 2/4 t-reftable-readwrite: use free_names() instead of a for loopChandra Pratap, Aug 9, 2024
  16. Junio C HamanoAug 9, 2024
  17. Chandra PratapAug 10, 2024
  18. Junio C HamanoAug 10, 2024
  19. 3/4 t-reftable-readwrite: use 'for' in place of infinite 'while' loopsChandra Pratap, Aug 9, 2024
  20. Junio C HamanoAug 9, 2024
  21. 4/4 t-reftable-readwrite: add test for known errorChandra Pratap, Aug 9, 2024
  22. [GSoC][PATCH v3 0/4] t: port reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 13, 2024
  23. 1/4 t: move reftable/readwrite_test.c to the unit testing frameworkChandra Pratap, Aug 13, 2024
  24. Josh SteadmonAug 13, 2024
  25. Chandra PratapAug 14, 2024
  26. Patrick SteinhardtAug 14, 2024
  27. 2/4 t-reftable-readwrite: use free_names() instead of a for loopChandra Pratap, Aug 13, 2024
  28. 3/4 t-reftable-readwrite: use 'for' in place of infinite 'while' loopsChandra Pratap, Aug 13, 2024
  29. 4/4 t-reftable-readwrite: add test for known errorChandra Pratap, Aug 13, 2024
  30. Junio C HamanoAug 13, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.