help the compiler create more efficient code

Patch from Michael <virtual_worlds@gmx.de>
Full text: As usual I have modified only minor things to remove warnigs when compiled as C++ code, have added some const-specifiers where possible to help the compiler create more efficient code and added some static-specifiers to make functions invisible to other modules.
This commit is contained in:
Robin Stuart
2017-05-29 10:43:47 +01:00
parent d08237d06e
commit b3a1b24d18
29 changed files with 275 additions and 298 deletions

View File

@ -66,7 +66,7 @@ static const int dot_patterns[113] = {
0x1b8, 0x1c6, 0x1cc
};
int get_dot(char Dots[], int Hgt, int Wid, int x, int y) {
static int get_dot(char Dots[], const int Hgt, const int Wid, const int x, const int y) {
int retval = 0;
if ((x >= 0) && (x < Wid) && (y >= 0) && (y < Hgt)) {
@ -78,7 +78,7 @@ int get_dot(char Dots[], int Hgt, int Wid, int x, int y) {
return retval;
}
int clr_col(char *Dots, int Hgt, int Wid, int x) {
static int clr_col(char *Dots, const int Hgt, const int Wid, const int x) {
int y;
for (y = x & 1; y < Hgt; y += 2) {
if (get_dot(Dots, Hgt, Wid, x, y)) {
@ -89,7 +89,7 @@ int clr_col(char *Dots, int Hgt, int Wid, int x) {
return 1;
}
int clr_row(char *Dots, int Hgt, int Wid, int y) {
static int clr_row(char *Dots, const int Hgt, const int Wid, const int y) {
int x;
for (x = y & 1; x < Wid; x += 2) {
if (get_dot(Dots, Hgt, Wid, x, y)) {
@ -101,7 +101,7 @@ int clr_row(char *Dots, int Hgt, int Wid, int y) {
}
/* Dot pattern scoring routine from Annex A */
int score_array(char Dots[], int Hgt, int Wid) {
const int score_array(char Dots[], int Hgt, int Wid) {
int x, y, worstedge, first, last, sum;
int penalty_local = 0;
int penalty = 0;
@ -1192,9 +1192,9 @@ void fold_dotstream(char dot_stream[], int width, int height, char dot_array[])
int dotcode(struct zint_symbol *symbol, const unsigned char source[], int length) {
int i, j, k;
size_t jc;
size_t jc, n_dots;
int data_length, ecc_length;
int min_dots, n_dots, min_area;
int min_dots, min_area;
int height, width;
int mask_score[4];
int weight;