[rkward-cvs] SF.net SVN: rkward:[2465] trunk/rkward/rkward/rbackend

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon May 11 17:29:57 UTC 2009


Revision: 2465
          http://rkward.svn.sourceforge.net/rkward/?rev=2465&view=rev
Author:   tfry
Date:     2009-05-11 17:29:54 +0000 (Mon, 11 May 2009)

Log Message:
-----------
Use more QStringLists

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rinterface.cpp
    trunk/rkward/rkward/rbackend/rthread.cpp
    trunk/rkward/rkward/rbackend/rthread.h

Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp	2009-05-11 17:14:54 UTC (rev 2464)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp	2009-05-11 17:29:54 UTC (rev 2465)
@@ -2,7 +2,7 @@
                           rinterface.cpp  -  description
                              -------------------
     begin                : Fri Nov 1 2002
-    copyright            : (C) 2002, 2004, 2005, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2002, 2004, 2005, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2009-05-11 17:14:54 UTC (rev 2464)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2009-05-11 17:29:54 UTC (rev 2465)
@@ -2,7 +2,7 @@
                           rthread  -  description
                              -------------------
     begin                : Mon Aug 2 2004
-    copyright            : (C) 2004, 2006, 2007, 2008 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2008, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -47,11 +47,6 @@
 	current_output = 0;
 	out_buf_len = 0;
 	output_paused = false;
-
-	toplevel_env_names = 0;
-	toplevel_env_count = 0;
-	global_env_toplevel_names = 0;
-	global_env_toplevel_count = 0;
 }
 
 RThread::~RThread() {
@@ -558,43 +553,44 @@
 	// TODO: avoid parsing this over and over again
 		RK_DO (qDebug ("checkObjectUpdatesNeeded: getting search list"), RBACKEND, DL_TRACE);
 		strings = getCommandAsStringVector ("search ()\n", &count, &error);
-		if (count != toplevel_env_count) {
+		if ((int) count != toplevel_env_names.count ()) {
 			search_update_needed = true;
 		} else {
-			for (unsigned int i = 0; i < toplevel_env_count; ++i) {
+			for (unsigned int i = 0; i < count; ++i) {
+				// order is important in the search path
 				if (toplevel_env_names[i] != strings[i]) {
 					search_update_needed = true;
 					break;
 				}
 			}
 		}
-		delete [] toplevel_env_names;
-		toplevel_env_names = strings;
-		toplevel_env_count = count;
+		if (search_update_needed) {
+			toplevel_env_names.clear ();
+			for (unsigned int i = 0; i < count; ++i) {
+				toplevel_env_names.append (strings[i]);
+			}
+		}
 	
 	// TODO: avoid parsing this over and over again
 		RK_DO (qDebug ("checkObjectUpdatesNeeded: getting globalenv symbols"), RBACKEND, DL_TRACE);
 		strings = getCommandAsStringVector ("ls (globalenv (), all.names=TRUE)\n", &count, &error);
-		if (count != global_env_toplevel_count) {
+		if ((int) count != global_env_toplevel_names.count ()) {
 			globalenv_update_needed = true;
 		} else {
-			for (unsigned int i = 0; i < global_env_toplevel_count; ++i) {
-				bool found = false;
-				for (unsigned int j = 0; j < global_env_toplevel_count; ++j) {
-					if (global_env_toplevel_names[j] == strings[i]) {
-						found = true;
-						break;
-					}
-				}
-				if (!found) {
+			for (unsigned int i = 0; i < count; ++i) {
+				// order is not important in the symbol list
+				if (!global_env_toplevel_names.contains (strings[i])) {
 					globalenv_update_needed = true;
 					break;
 				}
 			}
 		}
-		delete [] global_env_toplevel_names;
-		global_env_toplevel_names = strings;
-		global_env_toplevel_count = count;
+		if (globalenv_update_needed) {
+			global_env_toplevel_names.clear ();
+			for (unsigned int i = 0; i < count; ++i) {
+				global_env_toplevel_names.append (strings[i]);
+			}
+		}
 	
 		if (search_update_needed) {	// this includes an update of the globalenv, even if not needed
 			MUTEX_UNLOCK;

Modified: trunk/rkward/rkward/rbackend/rthread.h
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.h	2009-05-11 17:14:54 UTC (rev 2464)
+++ trunk/rkward/rkward/rbackend/rthread.h	2009-05-11 17:29:54 UTC (rev 2465)
@@ -203,13 +203,9 @@
 	bool output_paused;
 
 /** A copy of the names of the toplevel environments (as returned by "search ()"). */
-	QString *toplevel_env_names;
-/** number of toplevel environments */
-	unsigned int toplevel_env_count;
+	QStringList toplevel_env_names;
 /** A copy of the names of the toplevel symbols in the .GlobalEnv. */
-	QString *global_env_toplevel_names;
-/** number of symbols in .GlobalEnv */
-	unsigned int global_env_toplevel_count;
+	QStringList global_env_toplevel_names;
 /** A list of symbols that have been assigned new values during the current command */
 	QStringList changed_symbol_names;
 /** check wether the object list / global environment / individual symbols have changed, and updates them, if needed */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list