Skip to content
  • Damien George's avatar
    py/objnamedtuple: Simplify and remove use of alloca building namedtuple. · 265500c5
    Damien George authored
    Prior to this patch there were 2 paths for creating the namedtuple, one for
    when no keyword args were passed, and one when there were keyword args.
    And alloca was used in the keyword-arg path to temporarily create the array
    of elements for the namedtuple, which would then be copied to a
    heap-allocated object (the namedtuple itself).
    
    This patch simplifies the code by combining the no-keyword and keyword
    paths, and removing the need for the alloca by constructing the namedtuple
    on the heap before populating it.
    
    Heap usage in unchanged, stack usage is reduced, use of alloca is removed,
    and code size is not increased and is actually reduced by between 20-30
    bytes for most ports.
    265500c5