Show a patch.

GET /api/patches/22035/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 22035,
    "url": "https://patchwork.libcamera.org/api/patches/22035/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/22035/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20241120142807.2093301-5-stefan.klug@ideasonboard.com>",
    "date": "2024-11-20T14:27:51",
    "name": "[v3,4/9] libcamera: internal: matrix: Replace vector with array in constructor",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b36414b9c3bac67eae1988b84abf347c139b6a44",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/users/17/?format=api",
        "username": "epaul",
        "first_name": "Paul",
        "last_name": "Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/22035/mbox/",
    "series": [
        {
            "id": 4809,
            "url": "https://patchwork.libcamera.org/api/series/4809/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4809",
            "date": "2024-11-20T14:27:47",
            "name": "Move Matrix class from libipa to libcamera",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4809/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/22035/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/22035/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>",
        "X-Original-To": "parsemail@patchwork.libcamera.org",
        "Delivered-To": "parsemail@patchwork.libcamera.org",
        "Received": [
            "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CB55AC330B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Nov 2024 14:28:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3AB1A65F6C;\n\tWed, 20 Nov 2024 15:28:27 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CE2F65F67\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Nov 2024 15:28:23 +0100 (CET)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:bbd:82cc:f3f3:e12e])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6EAB0AB5;\n\tWed, 20 Nov 2024 15:28:05 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"tmKdgyiM\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1732112885;\n\tbh=ijGutbxbl2X9YnUKzdIB7SeDg9SnLHwr/1Zvs4bqR60=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=tmKdgyiMxeCR7y4MvPPxfrdDNO4P+DMtHkiJwxzyrYwnlRdzdhvMp/978Gb6gGtUb\n\t1ZZqMrr0AszWfNXq5wm2HSC8UbixuamEP18DhM8kcc3gcBrnUuuF71YKX2geWFCwkW\n\tzupBwo3ssk9hCq4vKatv0kaFMl3s3E2hqbynZoSA=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Subject": "[PATCH v3 4/9] libcamera: internal: matrix: Replace vector with\n\tarray in constructor",
        "Date": "Wed, 20 Nov 2024 15:27:51 +0100",
        "Message-ID": "<20241120142807.2093301-5-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20241120142807.2093301-1-stefan.klug@ideasonboard.com>",
        "References": "<20241120142807.2093301-1-stefan.klug@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The Matrix constructor that takes a std::vector is meant and only used\nto initialize a Matrix from an initializer list. Using a std::vector is\nproblematic for two reasons. First, it requires constructing a vector,\ncopying the data from the initializer list, which is an expensive\noperation. Then, the vector size can't be verified at compile time,\nmaking the constructor unsafe.\n\nThe first issue could be solved by replacing the vector with a\nstd::initializer_list or a Span. The second issue would require checking\nthe initializer list size with a static assertion, or restricting usage\nof the constructor to fixed-extent spans. Unfortunately, even if the\nsize of initializer lists is always known at compile time, the\nstd::initializer_list::size() function is a compile-time constant only\nfor constant initializer lists. Using a span would work better, but\nconstruction of a fixed extent span from an initializer list must be\nexplicit, making the API cumbersome.\n\nWe can solve all those issues by passing an std::array to the\nconstructor. Construction of an array from an initializer list can be\nimplicit and doesn't involve a copy, and the array size is a template\nparameter and therefore guaranteed to be a compile-time constant.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v3:\n- Collect tags\n- Update commit msg\n---\n include/libcamera/internal/matrix.h | 2 +-\n src/libcamera/matrix.cpp            | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/matrix.h b/include/libcamera/internal/matrix.h\nindex 3701d0ee980b..7a71028c473a 100644\n--- a/include/libcamera/internal/matrix.h\n+++ b/include/libcamera/internal/matrix.h\n@@ -33,7 +33,7 @@ public:\n \t\tdata_.fill(static_cast<T>(0));\n \t}\n \n-\tMatrix(const std::vector<T> &data)\n+\tMatrix(const std::array<T, Rows * Cols> &data)\n \t{\n \t\tstd::copy(data.begin(), data.end(), data_.begin());\n \t}\ndiff --git a/src/libcamera/matrix.cpp b/src/libcamera/matrix.cpp\nindex 55359aa206ee..4d95a19bfbb9 100644\n--- a/src/libcamera/matrix.cpp\n+++ b/src/libcamera/matrix.cpp\n@@ -32,7 +32,7 @@ LOG_DEFINE_CATEGORY(Matrix)\n  */\n \n /**\n- * \\fn Matrix::Matrix(const std::vector<T> &data)\n+ * \\fn Matrix::Matrix(const std::array<T, Rows * Cols> &data)\n  * \\brief Construct a matrix from supplied data\n  * \\param[in] data Data from which to construct a matrix\n  *\n",
    "prefixes": [
        "v3",
        "4/9"
    ]
}