Just use size as hash

This commit is contained in:
Kovid Goyal 2019-07-25 22:15:31 +05:30
parent 66b7037cd2
commit e080435407
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 7 deletions

View File

@ -840,7 +840,7 @@ def convert(opf_path, opts, metadata=None, output_path=None, log=default_log, co
merge_fonts(pdf_doc)
num_removed = dedup_type3_fonts(pdf_doc)
if num_removed:
log('Removed', num_removed, 'unused Type3 glyphs')
log('Removed', num_removed, 'duplicated Type3 glyphs')
# TODO: Support for mathematics

View File

@ -359,30 +359,28 @@ merge_fonts(PDFDoc *self, PyObject *args) {
class CharProc {
char *buf; pdf_long sz;
PdfReference ref;
std::size_t precomputed_hash;
CharProc( const CharProc & ) ;
CharProc & operator=( const CharProc & ) ;
public:
CharProc(const PdfReference &reference, const PdfObject *o) : buf(NULL), sz(0), ref(reference), precomputed_hash(0) {
CharProc(const PdfReference &reference, const PdfObject *o) : buf(NULL), sz(0), ref(reference) {
const PdfStream *stream = o->GetStream();
stream->GetFilteredCopy(&buf, &sz);
precomputed_hash = std::hash<pdf_long>()(sz);
}
CharProc(CharProc &&other) noexcept :
buf(other.buf), sz(other.sz), ref(other.ref), precomputed_hash(other.precomputed_hash) {
buf(other.buf), sz(other.sz), ref(other.ref) {
other.buf = NULL;
}
CharProc& operator=(CharProc &&other) noexcept {
if (buf) podofo_free(buf);
buf = other.buf; other.buf = NULL; sz = other.sz; ref = other.ref; precomputed_hash = other.precomputed_hash;
buf = other.buf; other.buf = NULL; sz = other.sz; ref = other.ref;
return *this;
}
~CharProc() noexcept { if (buf) podofo_free(buf); buf = NULL; }
bool operator==(const CharProc &other) const noexcept {
return other.sz == sz && memcmp(buf, other.buf, sz) == 0;
}
std::size_t hash() const noexcept { return precomputed_hash; }
std::size_t hash() const noexcept { return sz; }
const PdfReference& reference() const noexcept { return ref; }
};