diff options
| author | Simon Tatham <anakin@pobox.com> | 2001-10-25 19:08:52 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2001-10-25 19:08:52 +0000 |
| commit | dd9eaf09d344a4b18b2750cef08795a097891c08 (patch) | |
| tree | 29c028a1066a3ad287fd62f88b8b5996ba791658 /bk_xhtml.c | |
| parent | 63faea3d4c7f14d4c002bf4771375228641afa9d (diff) | |
| download | halibut-dd9eaf09d344a4b18b2750cef08795a097891c08.zip halibut-dd9eaf09d344a4b18b2750cef08795a097891c08.tar.gz halibut-dd9eaf09d344a4b18b2750cef08795a097891c08.tar.bz2 halibut-dd9eaf09d344a4b18b2750cef08795a097891c08.tar.xz | |
Eliminate completely gratuitous tail recursion in three functions
[originally from svn r1328]
Diffstat (limited to 'bk_xhtml.c')
| -rw-r--r-- | bk_xhtml.c | 38 |
1 files changed, 19 insertions, 19 deletions
@@ -815,11 +815,11 @@ static int xhtml_do_naked_contents(FILE *fp, xhtmlfile *file) static int xhtml_do_contents_limit(FILE *fp, xhtmlfile *file, int limit) { int count = 0; - if (!file) - return 0; - count += xhtml_do_contents_section_limit(fp, file->sections, limit); - count += xhtml_do_contents_limit(fp, file->child, limit); - count += xhtml_do_contents_limit(fp, file->next, limit); + while (file) { + count += xhtml_do_contents_section_limit(fp, file->sections, limit); + count += xhtml_do_contents_limit(fp, file->child, limit); + file = file->next; + } return count; } @@ -830,14 +830,14 @@ static int xhtml_do_contents_limit(FILE *fp, xhtmlfile *file, int limit) static int xhtml_do_contents_section_deep_limit(FILE *fp, xhtmlsection *section, int limit) { int count = 0; - if (!section) - return 0; - if (!xhtml_add_contents_entry(fp, section, limit)) - return 0; - else - count = 1; - count += xhtml_do_contents_section_deep_limit(fp, section->child, limit); - count += xhtml_do_contents_section_deep_limit(fp, section->next, limit); + while (section) { + if (!xhtml_add_contents_entry(fp, section, limit)) + return 0; + else + count++; + count += xhtml_do_contents_section_deep_limit(fp, section->child, limit); + section = section->next; + } return count; } @@ -894,12 +894,12 @@ static int xhtml_add_contents_entry(FILE *fp, xhtmlsection *section, int limit) */ static void xhtml_do_sections(FILE *fp, xhtmlsection *sections) { - if (!sections) - return; - currentsection = sections; - xhtml_do_paras(fp, sections->para); - xhtml_do_sections(fp, sections->child); - xhtml_do_sections(fp, sections->next); + while (sections) { + currentsection = sections; + xhtml_do_paras(fp, sections->para); + xhtml_do_sections(fp, sections->child); + sections = sections->next; + } } /* Write this list of paragraphs. Close off all lists at the end. */ |