From bb9e38286dd381363d3b6494eaca2d25c828155a Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Fri, 25 Oct 2002 04:08:52 +0000 Subject: [PATCH] more efficient replace --- direct/src/showbase/PythonUtil.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index f5a17bbe96..2a3a9c8379 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -374,10 +374,11 @@ def replace(list, old, new, all=0): list[i] = new return 1 else: - numReplaced = list.count(old) - for i in xrange(numReplaced): - ind = list.index(old) - list[ind] = new + numReplaced = 0 + for i in xrange(len(list)): + if list[i] == old: + numReplaced += 1 + list[i] = new return numReplaced def reduceAngle(deg):