Index: trunk/FACT++/src/InterpreterV8.cc
===================================================================
--- trunk/FACT++/src/InterpreterV8.cc	(revision 15133)
+++ trunk/FACT++/src/InterpreterV8.cc	(revision 15138)
@@ -148,7 +148,7 @@
     TryCatch exception;
 
-    const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));
-    if (sleep.IsEmpty())
-        return Undefined();
+    //const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));
+    //if (sleep.IsEmpty())
+    //    return Undefined();
 
     Handle<Function> func = Handle<Function>::Cast(args[1]);
@@ -171,5 +171,11 @@
         // JavaScript ever now and then. This also allows us to catch
         // exceptions, either from the preemption or ConvertEvent
-        sleep->Run();
+        //sleep->Run();
+
+        // Theoretically, the CPU usage can be reduced by maybe a factor
+        // of four using a larger value, but this also means that the
+        // JavaScript is locked for a longer time.
+        const Unlocker unlock;
+        usleep(1000);
     }
 
@@ -1214,7 +1220,7 @@
     HandleScope handle_scope;
 
-    const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));
-    if (sleep.IsEmpty())
-        return Undefined();
+    //const Handle<Script> sleep = Script::Compile(String::New("v8.sleep();"), String::New("internal"));
+    //if (sleep.IsEmpty())
+    //    return Undefined();
 
     const Handle<String> data   = String::New("data");
@@ -1273,5 +1279,11 @@
         // JavaScript ever now and then. This also allows us to catch
         // exceptions, either from the preemption or ConvertEvent
-        sleep->Run();
+        //sleep->Run();
+
+        // Theoretically, the CPU usage can be reduced by maybe a factor
+        // of four using a larger value, but this also means that the
+        // JavaScript is locked for a longer time.
+        const Unlocker unlock;
+        usleep(1000);
     }
 
@@ -2215,4 +2227,9 @@
         "{"
             "return String.form(this, Array.prototype.slice.call(arguments));"
+        "}"
+        "\n"
+        "String.prototype.count = function(c,i)"
+        "{"
+            "return (this.match(new RegExp(c,i?'gi':'g'))||[]).length;"
         "}"/*
         "\n"
