Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -r1.189.2.134 -r1.189.2.135 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 5 Sep 2022 15:57:38 -0000 1.189.2.134 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 5 Sep 2022 16:32:13 -0000 1.189.2.135 @@ -2218,63 +2218,15 @@ @author Peter Marklund } { - if { [llength $list1] == 0 } { - # The empty list is always a subset of any list - return [list] - } + set missing [list] - set sorted_list1 [list] - foreach elm [lsort $list1] { - if { [llength $sorted_list1] == 0 || [lindex $sorted_list1 end] ne $elm } { - lappend sorted_list1 $elm + foreach e $list1 { + if {$e ni $list2 && $e ni $missing} { + lappend missing $e } } - set sorted_list2 [lsort $list2] - set len1 [llength $sorted_list1] - set len2 [llength $sorted_list2] - - set missing_elms [list] - - # Loop over list1 and list2 in sort order, comparing the elements - - set index1 0 - set index2 0 - while { $index1 < $len1 && $index2 < $len2 } { - set elm1 [lindex $sorted_list1 $index1] - set elm2 [lindex $sorted_list2 $index2] - set compare [string compare $elm1 $elm2] - - switch -exact -- $compare { - -1 { - # elm1 < elm2 - # The first element in list1 is smaller than any element in list2, - # therefore this element cannot exist in list2, and therefore list1 is not a subset of list2 - lappend missing_elms $elm1 - incr index1 - } - 0 { - # A match, great, next element - incr index1 - incr index2 - continue - } - 1 { - # elm1 > elm2 - # Move to the next element in list2, knowing that this will be larger, and therefore - # potentially equal to the element in list1 - incr index2 - } - } - } - - if { $index1 == $len1 } { - # We've reached the end of list1, finding all elements along the way, we're done - return $missing_elms - } else { - # One or more elements in list1 not found in list2 - return [concat $missing_elms [lrange $sorted_list1 $index1 end]] - } + return $missing } ad_proc -public ad_tcl_list_list_to_ns_set {