From 25669a86e7ebc141063c0107e93b191fe4fd16d7 Mon Sep 17 00:00:00 2001 From: "Gregory J. Ward" Date: Thu, 12 Dec 2024 23:04:31 +0000 Subject: [PATCH] perf: Minor optimization --- src/common/mesh.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/common/mesh.c b/src/common/mesh.c index a30d6c63..ce482181 100644 --- a/src/common/mesh.c +++ b/src/common/mesh.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: mesh.c,v 2.36 2024/12/12 19:55:57 greg Exp $"; +static const char RCSid[] = "$Id: mesh.c,v 2.37 2024/12/12 23:04:31 greg Exp $"; #endif /* * Mesh support routines @@ -72,7 +72,7 @@ cvcmp(const char *vv1, const char *vv2) /* compare encoded vertices */ MESH * -getmesh( /* get new mesh data reference */ +getmesh( /* get mesh data reference */ char *mname, int flags ) @@ -82,20 +82,18 @@ getmesh( /* get new mesh data reference */ flags &= IO_LEGAL; for (ms = mlist; ms != NULL; ms = ms->next) - if (!strcmp(mname, ms->name)) { - ms->nref++; /* increase reference count */ + if (!strcmp(mname, ms->name)) break; - } if (ms == NULL) { /* new mesh entry? */ ms = (MESH *)calloc(1, sizeof(MESH)); if (ms == NULL) error(SYSTEM, "out of memory in getmesh"); ms->name = savestr(mname); - ms->nref = 1; ms->mcube.cutree = EMPTY; ms->next = mlist; mlist = ms; } + ms->nref++; /* bump reference count */ if (!(flags &= ~ms->ldflags)) /* nothing to load? */ return(ms); if ((pathname = getpath(mname, getrlibpath(), R_OK)) == NULL) {