Giter VIP home page Giter VIP logo

Comments (2)

aous72 avatar aous72 commented on May 24, 2024

Thank you for the suggestion.

I do not support moving the internal arrays to std::vector and the likes, for a few reasons.

The STL library wraps the simple structures I need with "cloaks," providing less visibility in what is going behind the scenes. Each std::vector has its own constructor/destructor, which can slow things down. I also need my arrays to have certain alignment. The codestream has a lot of structures, and it is impractical to do all this allocation/de-allocation of these data structures.

Using std::vectors does not protect against buffer overflows, unless we use the .at() function, which checks against the buffer boundary. We can do that as well, but it comes with performance hit. I understand the code has been written by more experienced programmers than myself. There's also assumption that the compiler would optimize out many of the functions.

IIRC, most libraries, such as openjpeg, libpng, libjpeg, ...etc. use C or C++ with little no STL structures. This might be due to historic reasons.

I am also not very knowledgeable in them, sorry.

For the supporting executable, I am not that resistant; certain parts might benefit from the use of STL.

I also do not like to make the library depends on other libraries -- boost, or others. This dependency creates headaches, which programmers have tried to solve using docker. I understand for large project that might be the only option, but for this project, I would like to keep it all in one place.

from openjph.

chafey avatar chafey commented on May 24, 2024

I understand your concerns here. STL is one approach to this - but there are others we can consider:

  1. We can create a Buffer class which encapsulates the pointer to allocated memory and length. This would increase safety while providing control and avoiding a third party dependency. The Buffer class can do bounds checking (maybe just in debug mode) for added safety
  2. Leverage C++ templates to generalize this Buffer class for strong typing (e.g. unsigned 16 bit, signed 16 bit, etc).

from openjph.

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.