Commit graph

10 commits

Author SHA1 Message Date
Berthold Stoeger
ad34652a6f cleanup: use std::size instead of custom macro
Since there is this standard construct, we might just use it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 22:01:23 +01:00
Berthold Stoeger
c1ba82bcc9 core: avoid pointless copying in git parser
When iterating over the converted strings of a line, the
first entry of the array would be popped off, leading to
a full copy of the remaining array.

Instead, use an index in the parser state.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 22:01:23 +01:00
Berthold Stoeger
0e46a12e01 core: directly generate std::strings in git parser
The converted strings were stored in a membuffer and later
converted to std::strings. Generate an std::string directly
to avoid unnecessary copying.

Ultimately, when the core structures are converted to
std::string, there should be no copying of the string data
at all (unless formatting is applied or small string
optimization kicks in, of course).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 22:01:23 +01:00
Berthold Stoeger
37994740ce core: remove alloc_filter_preset() and free_filter_preset()
All users of that are now C++ and don't need these helpers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 22:01:23 +01:00
Berthold Stoeger
615dd376f3 core: make get_sha() return std::string
This was crazy: it returned a local static buffer, i.e. was
inherently non-reentrant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
3e60f6c390 core: port printGPSCoordsC to return std::string
Less memory management hassle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
f9916652db core: use std::string in load-git.cpp
Make the memory management easier to follow. I feel that the old
code was leaking left and right, but not sure because it was so
intractable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 21:31:54 +01:00
Berthold Stoeger
9e97bbfb18 core: use std::string in parser state of git loader
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:59 +01:00
Berthold Stoeger
bf05dec52b core: turn saved_git_id into a std::string
Simplifies memory management. Think about unglobalizing this,
once everything is in C++ so that we can put an std::string
into struct divelog.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Berthold Stoeger
45cb0c09fc core: convert load-git.c to C++
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-02 20:50:58 +01:00
Renamed from core/load-git.c (Browse further)