OSDN Git Service

move qt_int_sqrt() function from qglobal to qtextdocument source file and make it...
authorIvailo Monev <xakepa10@laimg.moc>
Sat, 18 Jan 2020 00:06:51 +0000 (00:06 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Sat, 18 Jan 2020 00:06:51 +0000 (00:06 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/global/qglobal.cpp
src/gui/text/qtextdocument.cpp

index d4d907b..fa54b70 100644 (file)
@@ -1311,35 +1311,6 @@ void qt_assert_x(const char *where, const char *what, const char *file, int line
     qFatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line);
 }
 
-
-/*
-    Dijkstra's bisection algorithm to find the square root of an integer.
-    Deliberately not exported as part of the Qt API, but used in both
-    qsimplerichtext.cpp and qgfxraster_qws.cpp
-*/
-Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n)
-{
-    // n must be in the range 0...UINT_MAX/2-1
-    if (n >= (UINT_MAX>>2)) {
-        unsigned int r = 2 * qt_int_sqrt(n / 4);
-        unsigned int r2 = r + 1;
-        return (n >= r2 * r2) ? r2 : r;
-    }
-    uint h, p= 0, q= 1, r= n;
-    while (q <= n)
-        q <<= 2;
-    while (q != 1) {
-        q >>= 2;
-        h= p + q;
-        p >>= 1;
-        if (r >= h) {
-            p += q;
-            r -= h;
-        }
-    }
-    return p;
-}
-
 static QtMsgHandler handler = 0;                // pointer to debug handler
 
 QString qt_error_string(int errorCode)
index ffaa350..5e1d715 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
-Q_CORE_EXPORT unsigned int qt_int_sqrt(unsigned int n);
+/*
+    Dijkstra's bisection algorithm to find the square root of an integer.
+*/
+static uint qt_int_sqrt(uint n)
+{
+    // n must be in the range 0...UINT_MAX/2-1
+    if (n >= (UINT_MAX>>2)) {
+        uint r = 2 * qt_int_sqrt(n / 4);
+        uint r2 = r + 1;
+        return (n >= r2 * r2) ? r2 : r;
+    }
+    uint h, p= 0, q= 1, r= n;
+    while (q <= n)
+        q <<= 2;
+    while (q != 1) {
+        q >>= 2;
+        h= p + q;
+        p >>= 1;
+        if (r >= h) {
+            p += q;
+            r -= h;
+        }
+    }
+    return p;
+}
 
 /*!
     Returns true if the string \a text is likely to be rich text;