Code Monkey home page Code Monkey logo

Comments (10)

jtdaugherty avatar jtdaugherty commented on July 30, 2024

While thinking about this I went ahead and made a small improvement to the list API in d7bf9e1 which moved the list element drawing function from being in the list state itself to being a parameter to renderList, thus further separating the presentation and state concerns.

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

I also changed lists to use Vector e instead of [e] in 14d2147 since many vector operations are O(1) while their list counterparts are O(n).

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

I've pushed a commit (693abbb) to address this. The only user-facing change is that renderList now takes an item height (in rows) and all item widgets returned by the item drawing function must match that height (or else). It's in the feature/long-lists branch. Give that a try.

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

FYI: I tested this solution with lists of 100,000 elements and saw no discernible performance difference between those and lists with ten elements. The reason is because the vector slice operation that obtains the sub-list is O(1).

from brick.

simonmichael avatar simonmichael commented on July 30, 2024

Thank you! Sounds great. (Of course, my items are variable height; this will be strong incentive to change that).

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

Is that something your application needs? There might be other strategies, since you could always implement a custom widget and sidestep the List entirely. It would just be more work. :) But knowing that your elements all have the same height might have other benefits; I don't know.

from brick.

simonmichael avatar simonmichael commented on July 30, 2024

Currently when Ledger (and hledger's) register report contains multi-currency balances, each currency is shown on its own line.

In hledger's multicolumn balance reports, because this disrupted the tabular layout I changed this to show such balances on one line, comma separated. I plan do the same thing here.

from brick.

simonmichael avatar simonmichael commented on July 30, 2024

I confirm your latest List renders without the slowdown here too.

However I think str is no longer right-padding to the full terminal width. Eg with a box enclosing the list, each | of the box's right border is rendered immediately following the list element instead of at the terminal edge.

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

If you can reproduce using a minimal demo program and file an issue, I would be happy to take a look!

from brick.

jtdaugherty avatar jtdaugherty commented on July 30, 2024

I'm going to mull over the change for this ticket and decide wether to merge to master; I need to decide whether giving up mixed-height list items is problematic.

from brick.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.