#580 no need to iterate 1024 times to find a matching handler

There are only 41 handlers, no need to keep inspecting up to 1024.
Most entries in this array are null.
master
OpenGnSys Support Team 2018-10-30 21:39:56 +01:00
parent 8e0216a2ca
commit 4665749212
1 changed files with 3 additions and 2 deletions

View File

@ -3524,7 +3524,7 @@ BOOLEAN envioProgramacion(SOCKET *socket_c, TRAMA *ptrTrama)
static struct {
const char *nf; // Nombre de la función
BOOLEAN (*fptr)(SOCKET*,TRAMA*); // Puntero a la función que procesa la trama
} tbfuncionesServer[MAXIMAS_FUNCIONES] = {
} tbfuncionesServer[] = {
{ "Sondeo", Sondeo, },
{ "respuestaSondeo", respuestaSondeo, },
{ "ConsolaRemota", ConsolaRemota, },
@ -3567,6 +3567,7 @@ static struct {
{ "enviaArchivo", enviaArchivo, },
{ "recibeArchivo", recibeArchivo, },
{ "envioProgramacion", envioProgramacion, },
{ NULL, NULL, },
};
// ________________________________________________________________________________________________________
@ -3593,7 +3594,7 @@ BOOLEAN gestionaTrama(SOCKET *socket_c)
INTROaFINCAD(ptrTrama);
nfn = copiaParametro("nfn",ptrTrama); // Toma nombre de la función
for (i = 0; i < MAXIMAS_FUNCIONES; i++) { // Recorre funciones que procesan las tramas
for (i = 0; tbfuncionesServer[i].fptr; i++) {
res = strcmp(tbfuncionesServer[i].nf, nfn);
if (res == 0) { // Encontrada la función que procesa el mensaje
liberaMemoria(nfn);