Qian Yun
unread,May 1, 2024, 6:44:01 AM5/1/24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to fricas-devel
For "filecopy", it's absurd to do IO char by char.
For "|waitForViewport|", this is left over of the previous
"obey" -> "|run_shell_command|" change. Also avoid spawning
lot's of threads.
- Qian
diff --git a/src/graph/Gdraws/Gfun.c b/src/graph/Gdraws/Gfun.c
index 292f8b3b..2ec625c3 100644
--- a/src/graph/Gdraws/Gfun.c
+++ b/src/graph/Gdraws/Gfun.c
@@ -52,14 +52,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
* Given 2 file pointers, this function copies file ifp to file ofp
*/
+#define BUFFER_SIZE 4096
+
static void
filecopy(FILE * ifp, FILE * ofp)
{
-
- int c;
-
- while ((c = getc(ifp)) != EOF)
- putc(c, ofp);
+ size_t bytesRead;
+ char buffer[BUFFER_SIZE];
+ while ((bytesRead = fread(buffer, 1, BUFFER_SIZE, ifp)) > 0) {
+ fwrite(buffer, 1, bytesRead, ofp);
+ }
}
/*
diff --git a/src/interp/util.lisp b/src/interp/util.lisp
index 939ddd19..faced223 100644
--- a/src/interp/util.lisp
+++ b/src/interp/util.lisp
@@ -273,11 +273,11 @@ After this function is called the image is clean
and can be saved.
(defun |waitForViewport| ()
(progn
(do ()
- ((not (zerop (obey
+ ((not (zerop (|run_shell_command|
(concat
"ps "
|$ViewportProcessToWatch|
- " > /dev/null")))))
+ " > /dev/null && sleep 0.1")))))
())
(|sockSendInt| |$MenuServer| 1)
(|setIOindex| (- |$IOindex| 3))