From adc19f73209b30fa6b37a2d934b0bf71c6c5979c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Mon, 28 May 2007 13:50:00 +0200 Subject: [PATCH] Unblock threads while calculating a similarity. --- picard/util/astrcmp.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/picard/util/astrcmp.cpp b/picard/util/astrcmp.cpp index 54e87f1ee..4cbad426e 100644 --- a/picard/util/astrcmp.cpp +++ b/picard/util/astrcmp.cpp @@ -151,12 +151,21 @@ astrcmp(PyObject *self, PyObject *args) { PyObject *s1, *s2; float d; + const Py_UNICODE *us1, *us2; + int len1, len2; + PyThreadState *_save; if (!PyArg_ParseTuple(args, "UU", &s1, &s2)) return NULL; - d = LevenshteinDistance(PyUnicode_AS_UNICODE(s1), PyUnicode_GetSize(s1), - PyUnicode_AS_UNICODE(s2), PyUnicode_GetSize(s2)); + us1 = PyUnicode_AS_UNICODE(s1); + us2 = PyUnicode_AS_UNICODE(s2); + len1 = PyUnicode_GetSize(s1); + len2 = PyUnicode_GetSize(s2); + + Py_UNBLOCK_THREADS + d = LevenshteinDistance(us1, len1, us2, len2); + Py_BLOCK_THREADS return Py_BuildValue("f", d); }