Git Product home page Git Product logo

Comments (5)

lmichaelis avatar lmichaelis commented on September 21, 2024

Hm, that would mean that you should have observed slower load times everywhere, especially when loading the VOb tree. There might be optimisations that can be done in messages though.

from zenkit.

Try avatar Try commented on September 21, 2024

I've made a few experiment locally:

  1. removing std::stringstream - generally nice, but not critical improvement.

  2. replacing messages::_m_blocks_by_name to sort + binary search - work quite well

// messages messages::parse(buffer& buf)
...
   std::sort(msgs.blocks.begin(), msgs.blocks.end(), [](const message_block& l, const message_block& r){
      return l.name<r.name;
      });
   return msgs;
   }

const message_block* messages::block_by_name(std::string_view name) const {
    auto it = std::lower_bound(blocks.begin(), blocks.end(), name, [](const message_block& l, std::string_view name) {
      return l.name < name;
      });
    if (it!=blocks.end())
      return &*it;
    return nullptr;
    }

from zenkit.

lmichaelis avatar lmichaelis commented on September 21, 2024

It certainly makes sense that not allocating potentially thousands of small std::strings would make loading faster. Are you sure that in-game performance is actually acceptable using binary search instead of std::unordered_map's O(1) access times?

from zenkit.

Try avatar Try commented on September 21, 2024

Yes, I've tested this solution locally.
Also fetching block_by_name relatively rare case (roughly a 1 call per 3 seconds). Worst what can happen is spike at search call.

from zenkit.

lmichaelis avatar lmichaelis commented on September 21, 2024

Implemented :)

from zenkit.

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.