Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Timur Safin" <tsafin@tarantool.org>
To: 'Aleksandr Lyapunov' <alyapunov@tarantool.org>,
	tarantool-patches@dev.tarantool.org
Cc: v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 2/2] alter: use proper way to marry C	and C++
Date: Wed, 8 Jul 2020 13:41:34 +0300	[thread overview]
Message-ID: <022601d65514$59d7a560$0d86f020$@tarantool.org> (raw)
In-Reply-To: <1594199230-26036-3-git-send-email-alyapunov@tarantool.org>



: From: Aleksandr Lyapunov
: Subject: [Tarantool-patches] [PATCH 2/2] alter: use proper way to marry C
: and C++
: 
: We should not try-catch something that must not throw.
: It's dumb.
: 
: We should use function-try-block to convert C++ function to C.
: It's short, simple and does not create big intends.
: 
...
: @@ -2672,17 +2646,14 @@ on_replace_dd_index(struct trigger * /* trigger
: */, void *event)
:  		if (def == NULL)
:  			return -1;
:  		index_def_update_optionality(def, alter->new_min_field_count);
: -		try {
: -			if (def->opts.is_unique) {
: -				(void) new CreateConstraintID(
: -					alter, iid == 0 ? CONSTRAINT_TYPE_PK :
: -					CONSTRAINT_TYPE_UNIQUE, def->name);
: -			}
: -			(void) new CreateIndex(alter, def);
: -		} catch (Exception *e) {
: -			index_def_delete(def);
: -			return -1;
: +		auto guard = make_scoped_guard([=] { index_def_delete(def);
: });

I knew a lot of C++ code guidelines which specifically forbid 
capturing all arguments in C++ lambdas via copy or reference
and insist on explicit names passage. I do believe it makes some 
sense. What about to apply the same policy here and after? 


: +		if (def->opts.is_unique) {
: +			(void) new CreateConstraintID(
: +				alter, iid == 0 ? CONSTRAINT_TYPE_PK :
: +				CONSTRAINT_TYPE_UNIQUE, def->name);
:  		}
: +		(void) new CreateIndex(alter, def);
: +		guard.is_active = false;
:  	}
:  	/* Case 3 and 4: check if we need to rebuild index data. */
:  	if (old_index != NULL && new_tuple != NULL) {

Also, this operator new usage as wrapper around rlist operations 
looks ... not very much idiomatic, and unexpected at least (we do 
see new allocating memory which is instantly forgotten. WTF the 
immediate reaction). If we introduce here some sort of reference
counted allocations what about to wrap it somehow differently, 
say via templatized make_rlist_object<T> or something like that?
(even simple macros would looks clearer, IMVHO).

I'm not insisting on that approach, just saying...

Timur

  reply	other threads:[~2020-07-08 10:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08  9:07 [Tarantool-patches] [PATCH 0/2] Simplify alter.cc Aleksandr Lyapunov
2020-07-08  9:07 ` [Tarantool-patches] [PATCH 1/2] alter: use good c++ style Aleksandr Lyapunov
2020-07-11 19:53   ` Vladislav Shpilevoy
2020-07-13 13:36     ` Aleksandr Lyapunov
2020-07-13 18:33       ` Vladislav Shpilevoy
2020-07-13 21:51   ` Timur Safin
2020-07-13 22:17     ` Vladislav Shpilevoy
2020-07-08  9:07 ` [Tarantool-patches] [PATCH 2/2] alter: use proper way to marry C and C++ Aleksandr Lyapunov
2020-07-08 10:41   ` Timur Safin [this message]
2020-07-11 19:53   ` Vladislav Shpilevoy
2020-07-08  9:13 ` [Tarantool-patches] [PATCH 0/2] Simplify alter.cc Aleksandr Lyapunov
2020-07-08 10:35 ` Timur Safin
  -- strict thread matches above, loose matches on Subject: below --
2020-07-08  8:43 Aleksandr Lyapunov
2020-07-08  8:43 ` [Tarantool-patches] [PATCH 2/2] alter: use proper way to marry C and C++ Aleksandr Lyapunov

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='022601d65514$59d7a560$0d86f020$@tarantool.org' \
    --to=tsafin@tarantool.org \
    --cc=alyapunov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 2/2] alter: use proper way to marry C	and C++' \
    /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