Edit

kc3-lang/libxkbcommon/src/xkbcomp/parser-priv.h

Branch :

  • Show log

    Commit

  • Author : Ran Benita
    Date : 2025-02-02 22:29:05
    Hash : f4e95280
    Message : xkbcomp/scanner: avoid unneeded strdup of IDENT tokens The allocation is immediately discarded, either turned into a keysym or an atom. So use an sval slice into the input string instead strdup'ing. memusage ./release/bench-compile-keymap --iter=1000 --layout us,de --variant ,neo Before: Memory usage summary: heap total: 534063576, heap peak: 581022, stack peak: 18848 total calls total memory failed calls malloc| 11240525 291897104 0 realloc| 1447657 192307328 0 (nomove:37629, dec:0, free:0) calloc| 430573 49859144 0 free| 13993903 534063576 After: Memory usage summary: heap total: 506839909, heap peak: 581022, stack peak: 18960 total calls total memory failed calls malloc| 8016419 264673437 0 realloc| 1447657 192307328 0 (nomove:37278, dec:0, free:0) calloc| 430573 49859144 0 free| 10769797 506839909 Signed-off-by: Ran Benita <ran@unusedvar.com>

  • src/xkbcomp/parser-priv.h
  • /*
     * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
     * SPDX-License-Identifier: HPND
     */
    #pragma once
    
    struct parser_param;
    struct scanner;
    
    #include "scanner-utils.h"
    #include "parser.h"
    
    int
    _xkbcommon_lex(YYSTYPE *yylval, struct scanner *scanner);
    
    XkbFile *
    parse(struct xkb_context *ctx, struct scanner *scanner, const char *map);
    
    int
    keyword_to_token(const char *string, size_t len);