git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Daniel Ferreira <bnmvco@gmail.com>
Cc: git@vger.kernel.org, sbeller@google.com, pclouds@gmail.com,
	mhagger@alum.mit.edu
Subject: Re: [PATCH v9 4/5] dir_iterator: refactor state machine model
Date: Mon, 17 Apr 2017 21:35:16 -0700	[thread overview]
Message-ID: <xmqq4lxmfi4b.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1492462296-4990-5-git-send-email-bnmvco@gmail.com> (Daniel Ferreira's message of "Mon, 17 Apr 2017 17:51:35 -0300")

Daniel Ferreira <bnmvco@gmail.com> writes:

> Perform major refactor of dir_iterator_advance(). dir_iterator has
> ceased to rely on a convoluted state machine mechanism of two loops and
> two state variables (level.initialized and level.dir_state). This serves
> to ease comprehension of the iterator mechanism and ease addition of new
> features to the iterator.

I called 3/5 a "refactoring"; on the other hand, I wouldn't call
this refactoring--it is a major rewrite and/or enhancement.

Drop "convoluted...loops and variables"; instead spend the same
number of bits to explain how updated code is easier to follow.

> Add an option for the dir_iterator API to iterate over the root
> directory (the one it was initialized with) as well.

I had trouble understanding what you wanted to say with "iterate
over the root" because the phrase sounded, at least to me, to mean
"opendir the root directory and repeatedly issue readdir() calls,
returning each entry returned by them", and making that optional did
not make any sense to me.  I had to cheat by looking at the test
script to realize that you meant that the root directory that the
iterator is told to iterate over itself is also included in the
result, as opposed to the usual expectation that iterator would just
iterate over the contents of that directory recursively.  Perhaps

    Add an option for the API to also include the initial directory
    in the result.

or something like that?

By the way, some other topic already took t0065, so I moved your
t0065 over to t0066 while queuing.

> +/*
> + * This function uses a state machine with the following states:
> + * -> DIR_STATE_PUSHED: the directory has been pushed to the
> + * iterator traversal tree.
> + * -> DIR_STATE_PRE_ITERATION: the directory is *NOT* initialized. The
> + * dirpath has already been returned if pre-order traversal is set.
> + * -> DIR_STATE_ITERATING: the directory is initialized. We are traversing
> + * through it.
> + * -> DIR_STATE_POST_ITERATION: the directory has been iterated through.
> + * We are ready to close it.
> + * -> DIR_STATE_EXHAUSTED: the directory is closed and ready to be popped.
> + */

These "->" somehow makes it very hard to read; are these meant to be
bullets in a 5-item bulleted list, or do they mean more than that
(e.g. as an arrow, you are trying to say from state PUSHED there is
a transition to PRE_ITERATION, etc.)?

PRE_ITERATION says "*NOT* initialized"; has the directory been
already initialized in PUSHED state?  Instead of saying "*NOT*", it
may make it clearer if you say when it is initialized instead.

  reply	other threads:[~2017-04-18  4:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-17 20:51 [PATCH v9 0/5] [GSoC] remove_subtree(): reimplement using iterators Daniel Ferreira
2017-04-17 20:51 ` [PATCH v9 1/5] dir_iterator: add tests for dir_iterator API Daniel Ferreira
2017-04-18  4:12   ` Junio C Hamano
2017-04-18  4:37   ` Junio C Hamano
2017-04-17 20:51 ` [PATCH v9 2/5] remove_subtree(): test removing nested directories Daniel Ferreira
2017-04-17 20:51 ` [PATCH v9 3/5] dir_iterator: add helpers to dir_iterator_advance Daniel Ferreira
2017-04-18  4:23   ` Junio C Hamano
2017-04-17 20:51 ` [PATCH v9 4/5] dir_iterator: refactor state machine model Daniel Ferreira
2017-04-18  4:35   ` Junio C Hamano [this message]
2017-04-18  5:13   ` Junio C Hamano
2017-04-17 20:51 ` [PATCH v9 5/5] remove_subtree(): reimplement using iterators Daniel Ferreira
2017-04-18  4:09 ` [PATCH v9 0/5] [GSoC] " Junio C Hamano
2017-04-18 18:45   ` Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq4lxmfi4b.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=bnmvco@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=pclouds@gmail.com \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).