1
0
mirror of https://git.code.sf.net/p/zint/code synced 2025-12-18 18:37:07 +00:00

Performance improvements for linear encoding and raster output

- use fixed-length string tables (mostly) instead of (char *) pointer ones
   (saves ~40K)
 - re-use C128Table for CODABLOCKF and CODE16K
   (required removal of Stop character and extra CODE16K-only entry)
 - use pointer to destination and copy (memcpy/strcpy(), bin_append_posn())
   instead of concatenating (strcat()) (mostly)
 - replace last remaining bin_append()s with bin_append_posn();
   bin_append() removed
 - add length arg to toupper() and expand() (avoids strlen())
 - change is_sane() to use table-based flags (avoids an iteration)
 - rename lookup() to is_sane_lookup() and change to check and return posns
   and use in pointer to destination loops (avoids strcat()s)
 - remove special case PHARMA in expand() (dealt with in pharma())
 - make #define SILVER/CALCIUM/TECHNETIUM/KRSET etc static strings
 - replace strchr() -> posn()
 - CODE128: populate destination once in checksum loop; re-use and export
   some more routines (c128_set_a/b/c(), c128_put_in_set()) for sharing;
   prefix defines (SHIFTA -> C128_SHIFTA etc) and existing exported routines
 - use factor XOR toggle trick in checksum calcs (avoids branch)
 - raster.c: fill out single 1-pixel row and copy using new draw_bar_line(),
   copy_bar_line() routines; similarly in buffer_plot compare previous line &
   copy if same (same technique as used to improve non-half-integer scaling,
   significant performance increase, (c) codemonkey82);
   also done for PNG (BMP/GIF/PCX/TIFF not done)
 - raster/vector/output.c: shorten "output_" prefix -> "out_";
   sync vector to other raster changes to try to keep source files similar
 - 2of5.c: prefix "c25_"
JAPANPOST: return error if input data truncated (backward incompatible)
DAFT: max chars 50 -> 100
common.c: istwodigit() -> is_twodigit()
common.c/emf.c/output.c: use some further stripf()s (MSVC6 float variations)
library.c: new check_output_args() helper
zint.h: add BARCODE_LAST marker and use in library.c
QRCODE: remove a NOLINT (requires clang-tidy-13), one remaining
CMake: separate no-optimize from ZINT_DEBUG into new ZINT_NOOPT option
This commit is contained in:
gitlost
2021-10-20 23:05:30 +01:00
parent e8b59aa696
commit fab7435fac
72 changed files with 3501 additions and 2380 deletions

View File

@@ -46,7 +46,7 @@
#define GFMUL(i, j) ((((i) == 0)||((j) == 0)) ? 0 : gfPwr[(gfLog[i] + gfLog[j])])
static const char fragment[27][14] = {"http://", "https://", "http://www.", "https://www.",
static const char fragment[27][13] = {"http://", "https://", "http://www.", "https://www.",
"ftp://", "www.", ".com", ".edu", ".gov", ".int", ".mil", ".net", ".org",
".mobi", ".coop", ".biz", ".info", "mailto:", "tel:", ".cgi", ".asp",
".aspx", ".php", ".htm", ".html", ".shtml", "file:"};
@@ -273,7 +273,7 @@ static float look_ahead_eightbit(unsigned char source[], int in_length, int in_l
*cw_len = codeword_count;
if (codeword_count == 0) {
return 0.0;
return 0.0f;
}
return (float) letters_encoded / (float) codeword_count;
}
@@ -362,7 +362,7 @@ static float look_ahead_ascii(unsigned char source[], int in_length, int in_locn
*cw_len = codeword_count;
if (codeword_count == 0) {
return 0.0;
return 0.0f;
}
return (float) letters_encoded / (float) codeword_count;
}
@@ -372,8 +372,8 @@ static int c43_should_latch_other(const unsigned char data[], const int length,
const int gs1) {
int i, fraglen, predict_window;
int cnt, alt_cnt, fragno;
const char *set = subset == 1 ? ultra_c43_set1 : ultra_c43_set2;
const char *alt_set = subset == 2 ? ultra_c43_set1 : ultra_c43_set2;
const char *const set = subset == 1 ? ultra_c43_set1 : ultra_c43_set2;
const char *const alt_set = subset == 2 ? ultra_c43_set1 : ultra_c43_set2;
if (locn + 3 > length) {
return 0;
@@ -394,10 +394,10 @@ static int c43_should_latch_other(const unsigned char data[], const int length,
}
i += fraglen - 1;
} else {
if (strchr(set, data[i]) != NULL) {
if (posn(set, data[i]) != -1) {
cnt++;
}
if (strchr(alt_set, data[i]) != NULL) {
if (posn(alt_set, data[i]) != -1) {
alt_cnt++;
}
}
@@ -612,7 +612,7 @@ static float look_ahead_c43(unsigned char source[], int in_length, int in_locn,
*cw_len = codeword_count;
if (codeword_count == 0) {
return 0.0;
return 0.0f;
}
return (float) letters_encoded / (float) codeword_count;
}