Skip to content

Commit

Permalink
Replace more GenericVector by std::vector for src/ccstruct
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Mar 19, 2021
1 parent 8ed6dee commit 65d882f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/ccstruct/fontinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void FontInfoTable::MoveSpacingInfoFrom(FontInfoTable *other) {
using namespace std::placeholders; // for _1, _2
set_clear_callback(std::bind(FontInfoDeleteCallback, _1));
for (int i = 0; i < other->size(); ++i) {
GenericVector<FontSpacingInfo *> *spacing_vec = other->get(i).spacing_vec;
std::vector<FontSpacingInfo *> *spacing_vec = other->get(i).spacing_vec;
if (spacing_vec != nullptr) {
int target_index = get_index(other->get(i));
if (target_index < 0) {
Expand Down Expand Up @@ -121,7 +121,9 @@ void FontInfoTable::MoveTo(UnicityTable<FontInfo> *target) {
// Callbacks for GenericVector.
void FontInfoDeleteCallback(FontInfo f) {
if (f.spacing_vec != nullptr) {
f.spacing_vec->delete_data_pointers();
for (auto data : *f.spacing_vec) {
delete data;
}
delete f.spacing_vec;
f.spacing_vec = nullptr;
}
Expand Down Expand Up @@ -187,7 +189,7 @@ bool write_spacing_info(FILE *f, const FontInfo &fi) {
return false;
int16_t x_gap_invalid = -1;
for (int i = 0; i < vec_size; ++i) {
FontSpacingInfo *fs = fi.spacing_vec->get(i);
FontSpacingInfo *fs = fi.spacing_vec->at(i);
int32_t kern_size = (fs == nullptr) ? -1 : fs->kerned_x_gaps.size();
if (fs == nullptr) {
// Writing two invalid x-gaps.
Expand Down
6 changes: 3 additions & 3 deletions src/ccstruct/fontinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ struct FontInfo {

// Reserves unicharset_size spots in spacing_vec.
void init_spacing(int unicharset_size) {
spacing_vec = new GenericVector<FontSpacingInfo *>();
spacing_vec->init_to_size(unicharset_size, nullptr);
spacing_vec = new std::vector<FontSpacingInfo *>();
spacing_vec->resize(unicharset_size);
}
// Adds the given pointer to FontSpacingInfo to spacing_vec member
// (FontInfo class takes ownership of the pointer).
Expand Down Expand Up @@ -137,7 +137,7 @@ struct FontInfo {
// ResultIterator::WordFontAttributes.
int32_t universal_id;
// Horizontal spacing between characters (indexed by UNICHAR_ID).
GenericVector<FontSpacingInfo *> *spacing_vec;
std::vector<FontSpacingInfo *> *spacing_vec;
};

// Every class (character) owns a FontSet that represents all the fonts that can
Expand Down

0 comments on commit 65d882f

Please sign in to comment.