mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Just use size as hash
This commit is contained in:
parent
66b7037cd2
commit
e080435407
@ -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
|
||||
|
||||
|
@ -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; }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user