From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E3FAF469719 for ; Mon, 16 Nov 2020 17:42:00 +0300 (MSK) Received: by mail-lf1-f66.google.com with SMTP id d17so25431565lfq.10 for ; Mon, 16 Nov 2020 06:42:00 -0800 (PST) Date: Mon, 16 Nov 2020 17:41:57 +0300 From: Cyrill Gorcunov Message-ID: <20201116144157.GP2021@grain> References: <20201105151808.456573-1-gorcunov@gmail.com> <20201105151808.456573-3-gorcunov@gmail.com> <4b185545-84c6-86d4-b89c-5059344d55c4@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4b185545-84c6-86d4-b89c-5059344d55c4@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v10 2/4] module_cache: move module handling into own subsystem List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tml On Thu, Nov 12, 2020 at 11:54:01PM +0100, Vladislav Shpilevoy wrote: > > + > > +/** > > + * Find a path to a module using Lua's package.cpath. > > + */ > > +static int > > +module_find(struct module_find_ctx *ctx) > > +{ > > 2. In the original code the function took package name and > path, which was way more clear than a ctx. Which in the > old code was constructed inside of this function. > > But you somewhy moved it to the caller code, to module_load(), > which creates the ctx just to call module_find(), and never > uses it again. So what was the point? I honestly do not > understand. Some more details on this function. Previously we have static int module_find(const char *package, const char *package_end, char *path, size_t path_len) { struct module_find_ctx ctx = { package, package_end, path, path_len }; lua_State *L = tarantool_L; int top = lua_gettop(L); if (luaT_cpcall(L, luaT_module_find, &ctx) != 0) { ... } The caller provides *all* 4 parameters which are then packed into module_find_ctx and sent to luaT_cpcall. The luaT_cpcall extracts them and fills the @path inside. Thus instead of passing module_find_ctx right from the point where path[] and path_len are allocated (ie just one argument) we pass 4 instead, for absolutely no reason. So bloody ugly :( I simply fixed it since I'm reworking this code. If you prefer I can do such transition as a separate patch before moving code into new place.