Show a patch.

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

{
    "id": 17900,
    "url": "https://patchwork.libcamera.org/api/patches/17900/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/17900/",
    "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": "<mailman.131.1669506152.939.libcamera-devel@lists.libcamera.org>",
    "date": "2022-11-26T23:42:27",
    "name": "[libcamera-devel,v1] libcamera: framebuffer_allocator: Avoid double map lookup",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "015f8cdc6d376f999cb0c9ede4469d4958cc5e77",
    "submitter": {
        "id": 133,
        "url": "https://patchwork.libcamera.org/api/people/133/?format=api",
        "name": "Pőcze Barnabás",
        "email": "pobrn@protonmail.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/17900/mbox/",
    "series": [
        {
            "id": 3643,
            "url": "https://patchwork.libcamera.org/api/series/3643/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3643",
            "date": "2022-11-26T23:42:27",
            "name": "[libcamera-devel,v1] libcamera: framebuffer_allocator: Avoid double map lookup",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3643/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/17900/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/17900/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 07D62BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 26 Nov 2022 23:42:35 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EED5C6332B;\n\tSun, 27 Nov 2022 00:42:33 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669506154;\n\tbh=dLM3dVvf1/NKZneAdyTJLCJz1pBc2XBZ127jcLqoguw=;\n\th=Date:To:List-Id:List-Post:From:List-Subscribe:List-Unsubscribe:\n\tList-Archive:Reply-To:List-Help:Subject:From;\n\tb=qDTpjPnan2rho96hQ2JSC8xnZkM8SmcidMShYpJ1SagVY4X1mjKHsugYlhLoK+2//\n\twePgX7eANEhQj1l4CZRvbqLsSw07ZlZRLE5LEcrZFXWFNZf9SB2HJrHPGo55ACLnVv\n\tYppSIQyj5qxkjcBvG9wgAuFqc5D5z9cnAe9bgXH+fSc8apOnCDVpjH5GrSfDOm7txB\n\t6ZrA2RxgDJ5lITTrEUyAl72vKFYAR/VdrNowCRkadS6NsqG64Q07HOg6MeB9L47wNj\n\tNhuaw8035cOLqKKRY8DcSMDxKxZVkV1tV9l6eFKbBVlHJq89Q8HUPMXXGo41roGsD7\n\tAJItAZ8ebG2qw==",
        "Date": "Sat, 26 Nov 2022 23:42:27 +0000",
        "To": "libcamera-devel@lists.libcamera.org",
        "MIME-Version": "1.0",
        "Message-ID": "<mailman.131.1669506152.939.libcamera-devel@lists.libcamera.org>",
        "List-Id": "<libcamera-devel.lists.libcamera.org>",
        "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>",
        "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze_via_libcamera-devel?=\n\t<libcamera-devel@lists.libcamera.org>",
        "Precedence": "list",
        "X-Mailman-Version": "2.1.29",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>",
        "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/>",
        "Reply-To": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>",
        "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>",
        "Subject": "[libcamera-devel] [PATCH v1] libcamera: framebuffer_allocator:\n\tAvoid double map lookup",
        "Content-Type": "message/rfc822",
        "Content-Disposition": "inline",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Use `try_emplace()` on the map instead of `count()`\nand `operator[]` to avoid walking the tree twice.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/libcamera/framebuffer_allocator.cpp | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\n--\n2.38.1",
    "diff": "diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp\nindex 4df27cac..17c5db49 100644\n--- a/src/libcamera/framebuffer_allocator.cpp\n+++ b/src/libcamera/framebuffer_allocator.cpp\n@@ -88,12 +88,14 @@ FrameBufferAllocator::~FrameBufferAllocator()\n  */\n int FrameBufferAllocator::allocate(Stream *stream)\n {\n-\tif (buffers_.count(stream)) {\n+\tconst auto &[ it, inserted ] = buffers_.try_emplace(stream);\n+\n+\tif (!inserted) {\n \t\tLOG(Allocator, Error) << \"Buffers already allocated for stream\";\n \t\treturn -EBUSY;\n \t}\n\n-\tint ret = camera_->exportFrameBuffers(stream, &buffers_[stream]);\n+\tint ret = camera_->exportFrameBuffers(stream, &it->second);\n \tif (ret == -EINVAL)\n \t\tLOG(Allocator, Error)\n \t\t\t<< \"Stream is not part of \" << camera_->id()\n",
    "prefixes": [
        "libcamera-devel",
        "v1"
    ]
}