-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Make list classes templated #4356
Conversation
…er classes (CLIST_LINK and CLIST_ITERATOR inside the list class). This allows us to use real C++ templates for different instantiations instead of void * emulation.
And we need this as part of updating memory management to unique ptrs. Feel free to contribute and push changes to this PR, so we can update things together (like Makefile changes). |
… be accessed as CLIST::ITERATOR etc.
Tested on windows, no regressions. |
part2 Converted ELIST, not pushing it at the moment to keep this PR more clear. Tested on windows.
|
And ELIST2 is completed. |
CI tests fail. Here is the first failure from
|
I see them running currently. Where is that error from? |
Ok, seems CIs are happy. Atleast what I see in this PR. |
It is probably worth to rename those lists to more clear names.
|
With the latest code (c3bf6a2) I now get a lot of compiler warnings like this one:
The unittests now seem to pass with sanitizers, too (still running). |
Reverted to classes. |
@egorpugin, are you planning to add more commits, or is your pull request now ready for review and merging? Did you compare old and new code size and performance? |
src/ccstruct/polyblk.cpp
Outdated
@@ -34,7 +34,7 @@ namespace tesseract { | |||
|
|||
#define INTERSECTING INT16_MAX | |||
|
|||
int lessthan(const void *first, const void *second); | |||
int lessthan(const ICOORDELT *first, const ICOORDELT *second); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int lessthan(const ICOORDELT *first, const ICOORDELT *second); | |
static int lessthan(const ICOORDELT *first, const ICOORDELT *second); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll reconsider those functions. Maybe change to lambdas one-use funcs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be fine for if this is done later. If you want, the PR can be merged as soon as the missing include statements which currently break my local build were added. Should we squash the commits, or do you prefer to keep them all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR has 2-3 unrelated tiny fixes around msvc warnings, sw build.
Not sure what is better here.
I'd prefer to keep separate commits because of separate changes to each of three lists.
src/ccstruct/polyblk.cpp
Outdated
const ICOORDELT *p1 = *reinterpret_cast<const ICOORDELT *const *>(first); | ||
const ICOORDELT *p2 = *reinterpret_cast<const ICOORDELT *const *>(second); | ||
|
||
int lessthan(const ICOORDELT *p1, const ICOORDELT *p2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int lessthan(const ICOORDELT *p1, const ICOORDELT *p2) { | |
static int lessthan(const ICOORDELT *p1, const ICOORDELT *p2) { |
@@ -19,16 +19,13 @@ | |||
#ifndef ELST_H | |||
#define ELST_H | |||
|
|||
#include "list.h" | |||
#include "lsterr.h" | |||
#include "serialis.h" | |||
|
|||
#include <cstdio> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <cstdio> | |
#include <algorithm> // for std::sort | |
#include <cstdio> |
@@ -19,696 +19,980 @@ | |||
#ifndef CLST_H | |||
#define CLST_H | |||
|
|||
#include "list.h" | |||
#include "lsterr.h" | |||
#include "serialis.h" | |||
|
|||
#include <cstdio> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <cstdio> | |
#include <algorithm> // for std::sort | |
#include <cstdio> |
@@ -19,16 +19,13 @@ | |||
#ifndef ELST2_H | |||
#define ELST2_H | |||
|
|||
#include "list.h" | |||
#include "lsterr.h" | |||
#include "serialis.h" | |||
|
|||
#include <cstdio> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <cstdio> | |
#include <algorithm> // for std::sort | |
#include <cstdio> |
I'll address your comments and we can merge after. I did not measure perf and size. |
Should be done now. Renaming lists, if necessary, and other changes can go into separate PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this nice work.
@egorpugin, I'm sorry, but I'm afraid that I was too fast: recodebeam_test and intsimdmatrix_test fail now. |
They fail before my changes. |
Yes, indeed. |
This is a part of lists de-entanglement PR series.
In order to simplify lists (old old C style code), we need to make them templates instead of types emulation using
void *
pointers.This PR handles the simplest class - CLIST.
See commit messages for details on changes.
No functional changes intended.
Make CLIST templated. Move member methods inside the class. Move help…
Use real CLASSNAME type for list. Update sorting callback signatures.
Make simple classes simpler.
cc: @stweil
ps.: I'd like to run tests on CI for this change, how can I do that now?