Skip to content

Commit f35eeb3

Browse files
committed
protos: Remove several unused macros, functions and global variables
The unused global variable TrainingData used a lot of runtime memory. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 5307b2c commit f35eeb3

File tree

2 files changed

+2
-152
lines changed

2 files changed

+2
-152
lines changed

src/classify/protos.cpp

+2-86
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
******************************************************************************
33
*
44
* File: protos.cpp (Formerly protos.c)
5-
* Description:
6-
* Author: Mark Seaman, OCR Technology
7-
* Created: Fri Oct 16 14:37:00 1987
8-
* Modified: Mon Mar 4 14:51:24 1991 (Dan Johnson) danj@hpgrlj
9-
* Language: C
10-
* Package: N/A
11-
* Status: Reusable Software Component
5+
* Author: Mark Seaman, OCR Technology
126
*
137
* (c) Copyright 1987, Hewlett-Packard Company.
148
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,9 +36,8 @@
4236
/*----------------------------------------------------------------------
4337
V a r i a b l e s
4438
----------------------------------------------------------------------*/
45-
CLASS_STRUCT TrainingData[NUMBER_OF_CLASSES];
4639

47-
STRING_VAR(classify_training_file, "MicroFeatures", "Training file");
40+
static STRING_VAR(classify_training_file, "MicroFeatures", "Training file");
4841

4942
/*----------------------------------------------------------------------
5043
F u n c t i o n s
@@ -128,65 +121,6 @@ int AddProtoToClass(CLASS_TYPE Class) {
128121
}
129122

130123

131-
/**
132-
* @name ClassConfigLength
133-
*
134-
* Return the length of all the protos in this class.
135-
*
136-
* @param Class The class to add to
137-
* @param Config FIXME
138-
*/
139-
float ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config) {
140-
int16_t Pid;
141-
float TotalLength = 0;
142-
143-
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
144-
if (test_bit (Config, Pid)) {
145-
146-
TotalLength += (ProtoIn (Class, Pid))->Length;
147-
}
148-
}
149-
return (TotalLength);
150-
}
151-
152-
153-
/**
154-
* @name ClassProtoLength
155-
*
156-
* Return the length of all the protos in this class.
157-
*
158-
* @param Class The class to use
159-
*/
160-
float ClassProtoLength(CLASS_TYPE Class) {
161-
int16_t Pid;
162-
float TotalLength = 0;
163-
164-
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
165-
TotalLength += (ProtoIn (Class, Pid))->Length;
166-
}
167-
return (TotalLength);
168-
}
169-
170-
171-
/**
172-
* @name CopyProto
173-
*
174-
* Copy the first proto into the second.
175-
*
176-
* @param Src Source
177-
* @param Dest Destination
178-
*/
179-
void CopyProto(PROTO Src, PROTO Dest) {
180-
Dest->X = Src->X;
181-
Dest->Y = Src->Y;
182-
Dest->Length = Src->Length;
183-
Dest->Angle = Src->Angle;
184-
Dest->A = Src->A;
185-
Dest->B = Src->B;
186-
Dest->C = Src->C;
187-
}
188-
189-
190124
/**********************************************************************
191125
* FillABC
192126
*
@@ -259,21 +193,3 @@ CLASS_TYPE NewClass(int NumProtos, int NumConfigs) {
259193
return (Class);
260194

261195
}
262-
263-
264-
/**********************************************************************
265-
* PrintProtos
266-
*
267-
* Print the list of prototypes in this class type.
268-
**********************************************************************/
269-
void PrintProtos(CLASS_TYPE Class) {
270-
int16_t Pid;
271-
272-
for (Pid = 0; Pid < Class->NumProtos; Pid++) {
273-
cprintf ("Proto %d:\t", Pid);
274-
PrintProto (ProtoIn (Class, Pid));
275-
cprintf ("\t");
276-
PrintProtoLine (ProtoIn (Class, Pid));
277-
tprintf("\n");
278-
}
279-
}

src/classify/protos.h

-66
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
******************************************************************************
33
*
44
* File: protos.h
5-
* Description:
65
* Author: Mark Seaman, SW Productivity
7-
* Created: Fri Oct 16 14:37:00 1987
8-
* Modified: Fri Jul 12 10:06:55 1991 (Dan Johnson) danj@hpgrlj
9-
* Language: C
10-
* Package: N/A
11-
* Status: Reusable Software Component
126
*
137
* (c) Copyright 1987, Hewlett-Packard Company.
148
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -69,20 +63,6 @@ struct CLASS_STRUCT {
6963
using CLASS_TYPE = CLASS_STRUCT*;
7064
using CLASSES = CLASS_STRUCT*;
7165

72-
/*----------------------------------------------------------------------
73-
C o n s t a n t s
74-
----------------------------------------------------------------------*/
75-
#define NUMBER_OF_CLASSES MAX_NUM_CLASSES
76-
#define Y_OFFSET -40.0
77-
#define FEATURE_SCALE 100.0
78-
79-
/*----------------------------------------------------------------------
80-
V a r i a b l e s
81-
----------------------------------------------------------------------*/
82-
extern CLASS_STRUCT TrainingData[];
83-
84-
extern STRING_VAR_H(classify_training_file, "MicroFeatures", "Training file");
85-
8666
/*----------------------------------------------------------------------
8767
M a c r o s
8868
----------------------------------------------------------------------*/
@@ -94,23 +74,6 @@ extern STRING_VAR_H(classify_training_file, "MicroFeatures", "Training file");
9474

9575
#define AddProtoToConfig(Pid, Config) (SET_BIT(Config, Pid))
9676

97-
/**
98-
* RemoveProtoFromConfig
99-
*
100-
* Clear a single proto bit in the specified configuration.
101-
*/
102-
103-
#define RemoveProtoFromConfig(Pid, Config) (reset_bit(Config, Pid))
104-
105-
/**
106-
* ClassOfChar
107-
*
108-
* Return the class of a particular ASCII character value.
109-
*/
110-
111-
#define ClassOfChar(Char) \
112-
((TrainingData[Char].NumProtos) ? (&TrainingData[Char]) : NO_CLASS)
113-
11477
/**
11578
* ProtoIn
11679
*
@@ -120,40 +83,13 @@ extern STRING_VAR_H(classify_training_file, "MicroFeatures", "Training file");
12083

12184
#define ProtoIn(Class, Pid) (&(Class)->Prototypes[Pid])
12285

123-
/**
124-
* PrintProto
125-
*
126-
* Print out the contents of a prototype. The 'Proto' argument is of
127-
* type 'PROTO'.
128-
*/
129-
130-
#define PrintProto(Proto) \
131-
(tprintf("X=%4.2f, Y=%4.2f, Length=%4.2f, Angle=%4.2f", Proto->X, Proto->Y, \
132-
Proto->Length, Proto->Angle))
133-
134-
/**
135-
* PrintProtoLine
136-
*
137-
* Print out the contents of a prototype. The 'Proto' argument is of
138-
* type 'PROTO'.
139-
*/
140-
141-
#define PrintProtoLine(Proto) \
142-
(cprintf("A=%4.2f, B=%4.2f, C=%4.2f", Proto->A, Proto->B, Proto->C))
143-
14486
/*----------------------------------------------------------------------
14587
F u n c t i o n s
14688
----------------------------------------------------------------------*/
14789
int AddConfigToClass(CLASS_TYPE Class);
14890

14991
int AddProtoToClass(CLASS_TYPE Class);
15092

151-
float ClassConfigLength(CLASS_TYPE Class, BIT_VECTOR Config);
152-
153-
float ClassProtoLength(CLASS_TYPE Class);
154-
155-
void CopyProto(PROTO Src, PROTO Dest);
156-
15793
void FillABC(PROTO Proto);
15894

15995
void FreeClass(CLASS_TYPE Class);
@@ -164,6 +100,4 @@ void InitPrototypes();
164100

165101
CLASS_TYPE NewClass(int NumProtos, int NumConfigs);
166102

167-
void PrintProtos(CLASS_TYPE Class);
168-
169103
#endif

0 commit comments

Comments
 (0)