Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Konstantin Osipov <kostja.osipov@gmail.com>
Cc: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH v2 3/8] json: lexer_eof and token_cmp helper functions
Date: Sat, 19 Oct 2019 17:08:48 +0200	[thread overview]
Message-ID: <33fd3f27-8a35-4d07-6da4-9bd7cd072949@tarantool.org> (raw)
In-Reply-To: <20191005135014.GI3913@atlas>

Hi! Thanks for the review!

On 05/10/2019 15:50, Konstantin Osipov wrote:
> * Vladislav Shpilevoy <v.shpilevoy@tarantool.org> [19/09/28 09:11]:
>>>>  /**
>>>> - * Compare JSON token keys.
>>>> + * Compare JSON tokens as nodes of a JSON tree. That is, including
>>>> + * parent references.
>>>>   */
>>>
>>> Please explain how it is useful. Why not json_tree_node_cmp then?
>>
>> What is useful? Being able to compare two JSON nodes? Not sure if I
>> understand the question. I just need to compare two nodes. In several
>> places. And I added a function for that.
> 
> How it is independently useful , given there still exists the old cmp function.
> You added a (yet) another cmp function, the comment should contain
> the usage scenario for it.
> 

Sorry, but it already looks like hypergraphia. This function's body
consists of 12 the simplest possible lines, including braces. Its
purpose is obvious. Just compare two tokens and return something that
is < 0, == 0, or > 0. What a usage scenario can there be except
comparison of two tokens?

You are saying, that all the code should be commented, each function
should be described, even a trivial one, but now I can definitely
say, that it is not necessary, and does not make life much easier. I am
working in a project, that is way bigger than Tarantool, and comments
are written for exceptional cases only, where code is not trivial. And
this does not harm at all. When code is easy to understand, comments
won't help to understand it even better. Moreover, they may confuse.
They become comments just for comments.

Here is the diff:

========================================================================

diff --git a/src/lib/json/json.h b/src/lib/json/json.h
index 08a0ee96c..3218769a1 100644
--- a/src/lib/json/json.h
+++ b/src/lib/json/json.h
@@ -288,7 +288,10 @@ json_token_is_leaf(struct json_token *token)
 
 /**
  * Compare two JSON tokens, not taking into account their tree
- * attributes.
+ * attributes. Only the token values are compared. That might be
+ * used to compare two JSON paths. String comparison of the paths
+ * may not work because the same token can be present in different
+ * forms: ['a'] == .a, for example.
  */
 static inline int
 json_token_cmp(const struct json_token *l, const struct json_token *r)

  parent reply	other threads:[~2019-10-19 15:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-31 21:35 [tarantool-patches] [PATCH v2 0/8] JSON updates Vladislav Shpilevoy
2019-08-31 21:35 ` [tarantool-patches] [PATCH v2 1/8] tuple: expose JSON go_to_key and go_to_index functions Vladislav Shpilevoy
2019-08-31 21:35 ` [tarantool-patches] [PATCH v2 2/8] tuple: rework updates to improve code extendibility Vladislav Shpilevoy
     [not found]   ` <20190903192059.GE15611@atlas>
     [not found]     ` <6ee759cf-a975-e6a9-6f52-f855958ffe06@tarantool.org>
     [not found]       ` <20191005132055.GD3913@atlas>
     [not found]         ` <20191005135037.GJ3913@atlas>
2019-10-19 15:11           ` [Tarantool-patches] [tarantool-patches] " Vladislav Shpilevoy
2019-08-31 21:35 ` [tarantool-patches] [PATCH v2 3/8] json: lexer_eof and token_cmp helper functions Vladislav Shpilevoy
     [not found]   ` <20190903192433.GF15611@atlas>
     [not found]     ` <f5612e04-dc56-f4bd-1298-c5841ac909f5@tarantool.org>
     [not found]       ` <20191005132231.GE3913@atlas>
     [not found]         ` <20191005135014.GI3913@atlas>
2019-10-19 15:08           ` Vladislav Shpilevoy [this message]
2019-08-31 21:35 ` [tarantool-patches] [PATCH v2 4/8] tuple: account the whole array in field.data and size Vladislav Shpilevoy
2019-08-31 21:35 ` [tarantool-patches] [PATCH v2 5/8] tuple: enable JSON bar updates Vladislav Shpilevoy
2019-08-31 21:35 ` [tarantool-patches] [PATCH v2 6/8] tuple: make update operation tokens consumable Vladislav Shpilevoy
2019-08-31 21:35 ` [tarantool-patches] [PATCH v2 7/8] tuple: JSON updates support intersection by arrays Vladislav Shpilevoy
2019-08-31 21:35 ` [tarantool-patches] [PATCH v2 8/8] tuple: JSON updates support intersection by maps Vladislav Shpilevoy

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

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

  git send-email \
    --in-reply-to=33fd3f27-8a35-4d07-6da4-9bd7cd072949@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja.osipov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [Tarantool-patches] [tarantool-patches] Re: [PATCH v2 3/8] json: lexer_eof and token_cmp helper functions' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox