Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework node struct #326

Merged
merged 8 commits into from
Jan 23, 2020
Merged

Rework node struct #326

merged 8 commits into from
Jan 23, 2020

Commits on Jan 23, 2020

  1. Configuration menu
    Copy the full SHA
    990bd94 View commit details
    Browse the repository at this point in the history
  2. Use C string instead of chunk for code info and literal

    Use zero-terminated C strings instead of cmark_chunks without storing
    the length. The length of code literals will be readded in a later
    commit. strlen overhead for code info should be negligible.
    
    Reduces size of struct cmark_node by 8 bytes.
    nwellnhof committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    150ef76 View commit details
    Browse the repository at this point in the history
  3. Use C string instead of chunk for link URL and title

    Use zero-terminated C strings instead of cmark_chunks without storing
    the length. This introduces a few additional strlen computations,
    but overhead should be low.
    
    Allows to reduce size of struct cmark_node later.
    nwellnhof committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    d52d52f View commit details
    Browse the repository at this point in the history
  4. Use C string instead of chunk for custom block contents

    Reduces size of struct cmark_node by 8 bytes.
    nwellnhof committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    accc7e9 View commit details
    Browse the repository at this point in the history
  5. Use C string instead of chunk for literal text

    Use zero-terminated C strings and a separate length field instead of
    cmark_chunks. Literal inline text will now be copied from the parent
    block's content buffer, slowing the benchmark down by 10-15%.
    
    The node struct never references memory of other nodes now, fixing commonmark#309.
    Node accessors don't have to check for delayed creation of C strings,
    so parsing and iterating all literals using the public API should
    actually be faster than before.
    nwellnhof committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    d994960 View commit details
    Browse the repository at this point in the history
  6. Use C string instead of chunk in renderer

    Fix another place where an "allocated" cmark_chunk was used.
    nwellnhof committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    0f61fdb View commit details
    Browse the repository at this point in the history
  7. Improve packing of struct cmark_list

    Allows to reduce size of struct cmark_node later.
    nwellnhof committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    5bb0931 View commit details
    Browse the repository at this point in the history
  8. Rearrange struct cmark_node

    Introduce multi-purpose data/len members in struct cmark_node. This
    is mainly used to store literal text for inlines, code and HTML blocks.
    
    Move the content strbuf for blocks from cmark_node to cmark_parser.
    When finalizing nodes that allow inlines (paragraphs and headings),
    detach the strbuf and store the block content in the node's data/len
    members. Free the block content after processing inlines.
    
    Reduces size of struct cmark_node by 8 bytes.
    nwellnhof committed Jan 23, 2020
    Configuration menu
    Copy the full SHA
    30c3095 View commit details
    Browse the repository at this point in the history