Просмотр исходного кода

Finally it seems that "SQFunctionProto::GetLineGetLine" using binary search is working properly now.
Thanks for the Squirrel author for this fix !

mingodad 12 лет назад
Родитель
Сommit
0d4c8f8dee
1 измененных файлов с 7 добавлено и 14 удалено
  1. 7 14
      SquiLu/squirrel/sqobject.cpp

+ 7 - 14
SquiLu/squirrel/sqobject.cpp

@@ -223,16 +223,8 @@ const SQChar* SQFunctionProto::GetLocal(SQVM *vm,SQUnsignedInteger stackbase,SQU
 
 
 SQInteger SQFunctionProto::GetLine(SQInstruction *curr)
 SQInteger SQFunctionProto::GetLine(SQInstruction *curr)
 {
 {
-	SQInteger op = (SQInteger)(curr-_instructions);
-	SQInteger line=_lineinfos[0]._line;
-	for(SQInteger i=1;i<_nlineinfos;i++){
-		if(_lineinfos[i]._op>=op)
-			return line;
-		line=_lineinfos[i]._line;
-	}
-	return line;
-#if 0
-    SQInteger op = (SQInteger)(curr-_instructions);
+	SQInteger op = (SQInteger)(curr-_instructions);
+    SQInteger line=_lineinfos[0]._line;
     SQInteger low = 0;
     SQInteger low = 0;
     SQInteger high = _nlineinfos - 1;
     SQInteger high = _nlineinfos - 1;
     SQInteger mid = 0;
     SQInteger mid = 0;
@@ -255,11 +247,12 @@ SQInteger SQFunctionProto::GetLine(SQInstruction *curr)
             break;
             break;
         }
         }
     }
     }
-
-    while(_lineinfos[mid]._op > op && mid >= 0) mid--;
 
 
-    return _lineinfos[mid]._line;
-#endif
+    while(mid > 0 && _lineinfos[mid]._op >= op) mid--; //I've changed this one
+
+    line = _lineinfos[mid]._line;
+
+    return line;
 }
 }
 
 
 SQClosure::~SQClosure()
 SQClosure::~SQClosure()