From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 473716EC55; Tue, 27 Jul 2021 17:07:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 473716EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1627394867; bh=kcTW+RRoMqPxZV7h6CcI93sRsof4QOI33hQS1RRVyz8=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ewpEpaVsM9kPfvEk3ILcf0n0gx6uuUdMdNupPd8c53DK/b3ojnoUTFwar4r4mquSz wLUptg9XWXTQGPKJb6S0gBEzcoUJSkg0m9HC1FagOVxYfSpoSyWjrSNzjK5VPQnMWx tvb2B4dCHOj7Rl3v9yhbHtdaEMcqTjODCzZTiTuM= Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id D57476EC55 for ; Tue, 27 Jul 2021 17:07:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D57476EC55 Received: by mail-lj1-f172.google.com with SMTP id x7so16049837ljn.10 for ; Tue, 27 Jul 2021 07:07:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YQXq6xa2Bnp7uoepZ5iR7F/oWSSOoMeqtbjpmfXC+UU=; b=q1rs/Ix6Pt+s6urUBb1rWGZTwJa1Md2ApMVIAws3K4xjOim/avMGyM/ZS+0AVzoi53 skFVY3jBMWXXhu0mNPyY2y0CRyLgO8sYhwRmOg2A/pLO/NNeOLJzZsUPtZFUepawbg6q F5G58yawyP7muuXw5zpmkTALgSV/qauEyN87QlgySUNoxO7KUlVK4L+GuZtw0xcIjgAs 9n5i7uXoeSA7EFagXtKab+b/uPcPyJ8cW/8dZNubHb8mcrOBZ/9hsgfsBjcwS6A3SZjL MVwSzzvCptS6nrhlC/AkasT4mj+A6f4wJR/Gyzy30OtzlsqEYUgtjS6YmhTKKs5H+uAn t1+A== X-Gm-Message-State: AOAM530DlCrlzMzClwVklKnUiyV0z8qkjz+u0iNaXrTXfxtqg1WRVzS8 l509vdCrHNvweuXq7qJYhIHqkIX4Hxw= X-Google-Smtp-Source: ABdhPJybMrAU6ufh4w0j58RrXKAGgTqJGcco3v4SGC+Sr654yLCO+GXn8dKx8Rrjsaxb1Hjm0CuCJw== X-Received: by 2002:a2e:9a05:: with SMTP id o5mr15597989lji.158.1627394864347; Tue, 27 Jul 2021 07:07:44 -0700 (PDT) Received: from grain.localdomain ([5.18.255.97]) by smtp.gmail.com with ESMTPSA id e13sm278645lji.106.2021.07.27.07.07.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jul 2021 07:07:43 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id ADF335A001E; Tue, 27 Jul 2021 17:07:42 +0300 (MSK) Date: Tue, 27 Jul 2021 17:07:42 +0300 To: Vladimir Davydov via Tarantool-patches Message-ID: References: <6c3509125f24f6276be678d6b8f1ac264631d048.1627024646.git.vdavydov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6c3509125f24f6276be678d6b8f1ac264631d048.1627024646.git.vdavydov@tarantool.org> User-Agent: Mutt/2.0.7 (2021-05-04) Subject: Re: [Tarantool-patches] [PATCH 11/20] net.box: rewrite response decoder in C X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On Fri, Jul 23, 2021 at 02:07:21PM +0300, Vladimir Davydov via Tarantool-patches wrote: > This patch moves method_decoder table from Lua to C. This is a step > towards rewriting performance-critical parts of net.box in C. ... > +static int > +netbox_decode_method(struct lua_State *L) > +{ > + typedef void (*method_decoder_f)(struct lua_State *L, const char **data, > + const char *data_end, > + struct tuple_format *format); > + static method_decoder_f method_decoder[] = { > + [NETBOX_PING] = netbox_decode_nil, > + [NETBOX_CALL_16] = netbox_decode_select, ... > + [NETBOX_INJECT] = netbox_decode_table, > + }; > + enum netbox_method method = lua_tointeger(L, 1); > + assert(method < netbox_method_MAX); Should not it be runtime testing like if (method < 0 || method >= lengthof(method_decoder) || method_decoder[method] == NULL) { // Some Lua error thrown return luaT_error(); } or we've validated this data somewhere already?