Raymond Toy pushed to branch issue-240-intersection-with-hash-table at cmucl / cmucl
Commits:
f577eda6 by Raymond Toy at 2023-07-23T22:38:00+00:00
Fix #244: Add c-call:signed-char
- - - - -
0411c386 by Raymond Toy at 2023-07-23T22:38:01+00:00
Merge branch 'issue-244-c-call-signed-char' into 'master'
Fix #244: Add c-call:signed-char
Closes #244
See merge request cmucl/cmucl!157
- - - - -
3e8b0a12 by Raymond Toy at 2023-07-26T13:43:15+00:00
Fix #245: Replace egrep with grep -E
- - - - -
24152f4d by Raymond Toy at 2023-07-26T13:43:15+00:00
Merge branch 'issue-245-replace-egrep-with-grep' into 'master'
Fix #245: Replace egrep with grep -E
Closes #245
See merge request cmucl/cmucl!158
- - - - -
5b27393f by Carl Shapiro at 2023-07-30T21:15:48-07:00
Guard against a division by zero in test run reports
- - - - -
a7300f03 by Carl Shapiro at 2023-07-31T05:28:58+00:00
Merge branch 'zero-tests' into 'master'
Guard against a division by zero when reporting test results
See merge request cmucl/cmucl!161
- - - - -
fef9f917 by Raymond Toy at 2023-07-31T13:38:26-07:00
Merge branch 'master' into issue-240-set-diff-with-hash-table
- - - - -
badda4b8 by Raymond Toy at 2023-07-31T13:45:09-07:00
Merge branch 'issue-240-set-diff-with-hash-table' into issue-240-intersection-with-hash-table
- - - - -
5 changed files:
- bin/clean-target.sh
- bin/make-extra-dist.sh
- src/code/c-call.lisp
- src/general-info/release-21f.md
- tests/run-tests.lisp
Changes:
=====================================
bin/clean-target.sh
=====================================
@@ -48,10 +48,10 @@ CORE='-o -name "*.core"'
if [ -n "$KEEP" ]; then
case $KEEP in
- lib) GREP='egrep -v'
+ lib) GREP='grep -Ev'
PATTERN='(gray-streams|gray-compat|simple-streams|iodefs|external-formats|clx|hemlock|clm)-library' ;;
core) CORE='' ;;
- all) GREP='egrep -v'
+ all) GREP='grep -Ev'
PATTERN='(gray-streams|gray-compat|simple-streams|iodefs|external-formats|clx|hemlock|clm)-library|(asdf|defsystem)'
CORE='' ;;
esac
=====================================
bin/make-extra-dist.sh
=====================================
@@ -94,12 +94,12 @@ install ${GROUP} ${OWNER} -m 0755 $TARGET/motif/server/motifd \
# Install the contrib stuff. Create the directories and then copy the files.
-for d in `(cd src; find contrib -type d -print | egrep -v "CVS|asdf|defsystem")`
+for d in `(cd src; find contrib -type d -print | grep -E -v "CVS|asdf|defsystem")`
do
install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib/$d
done
-for f in `(cd src/contrib; find . -type f -print | egrep -v "CVS|asdf|defsystem|unix")`
+for f in `(cd src/contrib; find . -type f -print | grep -E -v "CVS|asdf|defsystem|unix")`
do
FILE=`basename $f`
DIR=`dirname $f`
@@ -108,13 +108,13 @@ done
# Install all the locale data.
-for d in `(cd src/i18n/; find locale -type d -print | egrep -v CVS)`
+for d in `(cd src/i18n/; find locale -type d -print | grep -E -v CVS)`
do
install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib/$d
done
# Install mo files.
-for f in `(cd $TARGET/i18n; find locale -type f -print | egrep -v 'CVS|~.*~|.*~')`
+for f in `(cd $TARGET/i18n; find locale -type f -print | grep -E -v 'CVS|~.*~|.*~')`
do
FILE=`basename $f`
DIR=`dirname $f`
@@ -122,7 +122,7 @@ do
done
# Install po files. (Do we really need to distribute the po files?)
-#for f in `(cd $TARGET/i18n; find locale -type f -print | egrep -v 'CVS|~.*~|.*~')`
+#for f in `(cd $TARGET/i18n; find locale -type f -print | grep -E -v 'CVS|~.*~|.*~')`
#do
# FILE=`basename $f`
# DIR=`dirname $f`
=====================================
src/code/c-call.lisp
=====================================
@@ -19,7 +19,7 @@
(intl:textdomain "cmucl")
-(export '(char short int long long-long unsigned-char unsigned-short unsigned-int
+(export '(char short int long long-long signed-char unsigned-char unsigned-short unsigned-int
unsigned-long unsigned-long-long float double c-string void))
@@ -30,6 +30,8 @@
(def-alien-type int (integer 32))
(def-alien-type long (integer #-alpha 32 #+alpha 64))
(def-alien-type long-long (integer 64))
+;; The same as c-call:char, for convenience with C signed-char.
+(def-alien-type signed-char (integer 8))
(def-alien-type unsigned-char (unsigned 8))
(def-alien-type unsigned-short (unsigned 16))
=====================================
src/general-info/release-21f.md
=====================================
@@ -25,6 +25,7 @@ public domain.
* ~~#154~~ piglatin translation does not work anymore
* ~~#171~~ Readably print `(make-pathname :name :unspecfic)`
* ~~#242~~ Fix bug in `alien-funcall` with `c-call:char` as result type
+ * ~~#244~~ Add `c-call:signed-char`
* ~~#248~~ Print MOVS instruction with correct case
* Other changes:
* Improvements to the PCL implementation of CLOS:
=====================================
tests/run-tests.lisp
=====================================
@@ -110,9 +110,10 @@
(format t " ~5D tests failed~%" failed)
(format t " ~5D tests with execution errors~%" execute-errors)
(format t "~5,3f% of the tests passed~%"
- (float (* 100
- (- 1 (/ (+ failed execute-errors)
- (+ passed failed execute-errors))))))
+ (let ((total (+ passed failed execute-errors)))
+ (if (zerop total)
+ 0.0
+ (* 100.0 (- 1.0 (/ (- total passed) total))))))
;; Print some info about any failed tests. Then exit. We want to
;; set the exit code so that any scripts runnning this can
;; determine if there were any test failures.
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/807170e0ebb48ce16d2358…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/807170e0ebb48ce16d2358…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-240-union-with-hash-table at cmucl / cmucl
Commits:
f577eda6 by Raymond Toy at 2023-07-23T22:38:00+00:00
Fix #244: Add c-call:signed-char
- - - - -
0411c386 by Raymond Toy at 2023-07-23T22:38:01+00:00
Merge branch 'issue-244-c-call-signed-char' into 'master'
Fix #244: Add c-call:signed-char
Closes #244
See merge request cmucl/cmucl!157
- - - - -
3e8b0a12 by Raymond Toy at 2023-07-26T13:43:15+00:00
Fix #245: Replace egrep with grep -E
- - - - -
24152f4d by Raymond Toy at 2023-07-26T13:43:15+00:00
Merge branch 'issue-245-replace-egrep-with-grep' into 'master'
Fix #245: Replace egrep with grep -E
Closes #245
See merge request cmucl/cmucl!158
- - - - -
5b27393f by Carl Shapiro at 2023-07-30T21:15:48-07:00
Guard against a division by zero in test run reports
- - - - -
a7300f03 by Carl Shapiro at 2023-07-31T05:28:58+00:00
Merge branch 'zero-tests' into 'master'
Guard against a division by zero when reporting test results
See merge request cmucl/cmucl!161
- - - - -
fef9f917 by Raymond Toy at 2023-07-31T13:38:26-07:00
Merge branch 'master' into issue-240-set-diff-with-hash-table
- - - - -
ec9b0dcd by Raymond Toy at 2023-07-31T13:44:43-07:00
Merge branch 'issue-240-set-diff-with-hash-table' into issue-240-union-with-hash-table
- - - - -
5 changed files:
- bin/clean-target.sh
- bin/make-extra-dist.sh
- src/code/c-call.lisp
- src/general-info/release-21f.md
- tests/run-tests.lisp
Changes:
=====================================
bin/clean-target.sh
=====================================
@@ -48,10 +48,10 @@ CORE='-o -name "*.core"'
if [ -n "$KEEP" ]; then
case $KEEP in
- lib) GREP='egrep -v'
+ lib) GREP='grep -Ev'
PATTERN='(gray-streams|gray-compat|simple-streams|iodefs|external-formats|clx|hemlock|clm)-library' ;;
core) CORE='' ;;
- all) GREP='egrep -v'
+ all) GREP='grep -Ev'
PATTERN='(gray-streams|gray-compat|simple-streams|iodefs|external-formats|clx|hemlock|clm)-library|(asdf|defsystem)'
CORE='' ;;
esac
=====================================
bin/make-extra-dist.sh
=====================================
@@ -94,12 +94,12 @@ install ${GROUP} ${OWNER} -m 0755 $TARGET/motif/server/motifd \
# Install the contrib stuff. Create the directories and then copy the files.
-for d in `(cd src; find contrib -type d -print | egrep -v "CVS|asdf|defsystem")`
+for d in `(cd src; find contrib -type d -print | grep -E -v "CVS|asdf|defsystem")`
do
install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib/$d
done
-for f in `(cd src/contrib; find . -type f -print | egrep -v "CVS|asdf|defsystem|unix")`
+for f in `(cd src/contrib; find . -type f -print | grep -E -v "CVS|asdf|defsystem|unix")`
do
FILE=`basename $f`
DIR=`dirname $f`
@@ -108,13 +108,13 @@ done
# Install all the locale data.
-for d in `(cd src/i18n/; find locale -type d -print | egrep -v CVS)`
+for d in `(cd src/i18n/; find locale -type d -print | grep -E -v CVS)`
do
install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib/$d
done
# Install mo files.
-for f in `(cd $TARGET/i18n; find locale -type f -print | egrep -v 'CVS|~.*~|.*~')`
+for f in `(cd $TARGET/i18n; find locale -type f -print | grep -E -v 'CVS|~.*~|.*~')`
do
FILE=`basename $f`
DIR=`dirname $f`
@@ -122,7 +122,7 @@ do
done
# Install po files. (Do we really need to distribute the po files?)
-#for f in `(cd $TARGET/i18n; find locale -type f -print | egrep -v 'CVS|~.*~|.*~')`
+#for f in `(cd $TARGET/i18n; find locale -type f -print | grep -E -v 'CVS|~.*~|.*~')`
#do
# FILE=`basename $f`
# DIR=`dirname $f`
=====================================
src/code/c-call.lisp
=====================================
@@ -19,7 +19,7 @@
(intl:textdomain "cmucl")
-(export '(char short int long long-long unsigned-char unsigned-short unsigned-int
+(export '(char short int long long-long signed-char unsigned-char unsigned-short unsigned-int
unsigned-long unsigned-long-long float double c-string void))
@@ -30,6 +30,8 @@
(def-alien-type int (integer 32))
(def-alien-type long (integer #-alpha 32 #+alpha 64))
(def-alien-type long-long (integer 64))
+;; The same as c-call:char, for convenience with C signed-char.
+(def-alien-type signed-char (integer 8))
(def-alien-type unsigned-char (unsigned 8))
(def-alien-type unsigned-short (unsigned 16))
=====================================
src/general-info/release-21f.md
=====================================
@@ -25,6 +25,7 @@ public domain.
* ~~#154~~ piglatin translation does not work anymore
* ~~#171~~ Readably print `(make-pathname :name :unspecfic)`
* ~~#242~~ Fix bug in `alien-funcall` with `c-call:char` as result type
+ * ~~#244~~ Add `c-call:signed-char`
* ~~#248~~ Print MOVS instruction with correct case
* Other changes:
* Improvements to the PCL implementation of CLOS:
=====================================
tests/run-tests.lisp
=====================================
@@ -110,9 +110,10 @@
(format t " ~5D tests failed~%" failed)
(format t " ~5D tests with execution errors~%" execute-errors)
(format t "~5,3f% of the tests passed~%"
- (float (* 100
- (- 1 (/ (+ failed execute-errors)
- (+ passed failed execute-errors))))))
+ (let ((total (+ passed failed execute-errors)))
+ (if (zerop total)
+ 0.0
+ (* 100.0 (- 1.0 (/ (- total passed) total))))))
;; Print some info about any failed tests. Then exit. We want to
;; set the exit code so that any scripts runnning this can
;; determine if there were any test failures.
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/d864e30cda042c68bbaf4d…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/d864e30cda042c68bbaf4d…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl
Commits:
f577eda6 by Raymond Toy at 2023-07-23T22:38:00+00:00
Fix #244: Add c-call:signed-char
- - - - -
0411c386 by Raymond Toy at 2023-07-23T22:38:01+00:00
Merge branch 'issue-244-c-call-signed-char' into 'master'
Fix #244: Add c-call:signed-char
Closes #244
See merge request cmucl/cmucl!157
- - - - -
3e8b0a12 by Raymond Toy at 2023-07-26T13:43:15+00:00
Fix #245: Replace egrep with grep -E
- - - - -
24152f4d by Raymond Toy at 2023-07-26T13:43:15+00:00
Merge branch 'issue-245-replace-egrep-with-grep' into 'master'
Fix #245: Replace egrep with grep -E
Closes #245
See merge request cmucl/cmucl!158
- - - - -
5b27393f by Carl Shapiro at 2023-07-30T21:15:48-07:00
Guard against a division by zero in test run reports
- - - - -
a7300f03 by Carl Shapiro at 2023-07-31T05:28:58+00:00
Merge branch 'zero-tests' into 'master'
Guard against a division by zero when reporting test results
See merge request cmucl/cmucl!161
- - - - -
fef9f917 by Raymond Toy at 2023-07-31T13:38:26-07:00
Merge branch 'master' into issue-240-set-diff-with-hash-table
- - - - -
5 changed files:
- bin/clean-target.sh
- bin/make-extra-dist.sh
- src/code/c-call.lisp
- src/general-info/release-21f.md
- tests/run-tests.lisp
Changes:
=====================================
bin/clean-target.sh
=====================================
@@ -48,10 +48,10 @@ CORE='-o -name "*.core"'
if [ -n "$KEEP" ]; then
case $KEEP in
- lib) GREP='egrep -v'
+ lib) GREP='grep -Ev'
PATTERN='(gray-streams|gray-compat|simple-streams|iodefs|external-formats|clx|hemlock|clm)-library' ;;
core) CORE='' ;;
- all) GREP='egrep -v'
+ all) GREP='grep -Ev'
PATTERN='(gray-streams|gray-compat|simple-streams|iodefs|external-formats|clx|hemlock|clm)-library|(asdf|defsystem)'
CORE='' ;;
esac
=====================================
bin/make-extra-dist.sh
=====================================
@@ -94,12 +94,12 @@ install ${GROUP} ${OWNER} -m 0755 $TARGET/motif/server/motifd \
# Install the contrib stuff. Create the directories and then copy the files.
-for d in `(cd src; find contrib -type d -print | egrep -v "CVS|asdf|defsystem")`
+for d in `(cd src; find contrib -type d -print | grep -E -v "CVS|asdf|defsystem")`
do
install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib/$d
done
-for f in `(cd src/contrib; find . -type f -print | egrep -v "CVS|asdf|defsystem|unix")`
+for f in `(cd src/contrib; find . -type f -print | grep -E -v "CVS|asdf|defsystem|unix")`
do
FILE=`basename $f`
DIR=`dirname $f`
@@ -108,13 +108,13 @@ done
# Install all the locale data.
-for d in `(cd src/i18n/; find locale -type d -print | egrep -v CVS)`
+for d in `(cd src/i18n/; find locale -type d -print | grep -E -v CVS)`
do
install -d ${GROUP} ${OWNER} -m 0755 $DESTDIR/lib/cmucl/lib/$d
done
# Install mo files.
-for f in `(cd $TARGET/i18n; find locale -type f -print | egrep -v 'CVS|~.*~|.*~')`
+for f in `(cd $TARGET/i18n; find locale -type f -print | grep -E -v 'CVS|~.*~|.*~')`
do
FILE=`basename $f`
DIR=`dirname $f`
@@ -122,7 +122,7 @@ do
done
# Install po files. (Do we really need to distribute the po files?)
-#for f in `(cd $TARGET/i18n; find locale -type f -print | egrep -v 'CVS|~.*~|.*~')`
+#for f in `(cd $TARGET/i18n; find locale -type f -print | grep -E -v 'CVS|~.*~|.*~')`
#do
# FILE=`basename $f`
# DIR=`dirname $f`
=====================================
src/code/c-call.lisp
=====================================
@@ -19,7 +19,7 @@
(intl:textdomain "cmucl")
-(export '(char short int long long-long unsigned-char unsigned-short unsigned-int
+(export '(char short int long long-long signed-char unsigned-char unsigned-short unsigned-int
unsigned-long unsigned-long-long float double c-string void))
@@ -30,6 +30,8 @@
(def-alien-type int (integer 32))
(def-alien-type long (integer #-alpha 32 #+alpha 64))
(def-alien-type long-long (integer 64))
+;; The same as c-call:char, for convenience with C signed-char.
+(def-alien-type signed-char (integer 8))
(def-alien-type unsigned-char (unsigned 8))
(def-alien-type unsigned-short (unsigned 16))
=====================================
src/general-info/release-21f.md
=====================================
@@ -25,6 +25,7 @@ public domain.
* ~~#154~~ piglatin translation does not work anymore
* ~~#171~~ Readably print `(make-pathname :name :unspecfic)`
* ~~#242~~ Fix bug in `alien-funcall` with `c-call:char` as result type
+ * ~~#244~~ Add `c-call:signed-char`
* ~~#248~~ Print MOVS instruction with correct case
* Other changes:
* Improvements to the PCL implementation of CLOS:
=====================================
tests/run-tests.lisp
=====================================
@@ -110,9 +110,10 @@
(format t " ~5D tests failed~%" failed)
(format t " ~5D tests with execution errors~%" execute-errors)
(format t "~5,3f% of the tests passed~%"
- (float (* 100
- (- 1 (/ (+ failed execute-errors)
- (+ passed failed execute-errors))))))
+ (let ((total (+ passed failed execute-errors)))
+ (if (zerop total)
+ 0.0
+ (* 100.0 (- 1.0 (/ (- total passed) total))))))
;; Print some info about any failed tests. Then exit. We want to
;; set the exit code so that any scripts runnning this can
;; determine if there were any test failures.
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/b100ecd403f9ce701532d3…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/b100ecd403f9ce701532d3…
You're receiving this email because of your account on gitlab.common-lisp.net.
Carl Shapiro pushed to branch master at cmucl / cmucl
Commits:
5b27393f by Carl Shapiro at 2023-07-30T21:15:48-07:00
Guard against a division by zero in test run reports
- - - - -
a7300f03 by Carl Shapiro at 2023-07-31T05:28:58+00:00
Merge branch 'zero-tests' into 'master'
Guard against a division by zero when reporting test results
See merge request cmucl/cmucl!161
- - - - -
1 changed file:
- tests/run-tests.lisp
Changes:
=====================================
tests/run-tests.lisp
=====================================
@@ -110,9 +110,10 @@
(format t " ~5D tests failed~%" failed)
(format t " ~5D tests with execution errors~%" execute-errors)
(format t "~5,3f% of the tests passed~%"
- (float (* 100
- (- 1 (/ (+ failed execute-errors)
- (+ passed failed execute-errors))))))
+ (let ((total (+ passed failed execute-errors)))
+ (if (zerop total)
+ 0.0
+ (* 100.0 (- 1.0 (/ (- total passed) total))))))
;; Print some info about any failed tests. Then exit. We want to
;; set the exit code so that any scripts runnning this can
;; determine if there were any test failures.
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/24152f4d49b7226075dd52…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/24152f4d49b7226075dd52…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl
Commits:
b100ecd4 by Raymond Toy at 2023-07-27T17:59:17-07:00
Compute list length manual instead of calling length
For some strange reason, ansi-test `set-difference.error.11` fails in
`lisp::list-to-hashtable` which uses `length` to compute the length of
a list. Let's try computing the length manually ourselves.
- - - - -
1 changed file:
- src/code/list.lisp
Changes:
=====================================
src/code/list.lisp
=====================================
@@ -766,7 +766,11 @@
(return-from list-to-hashtable nil))
;; If the list is too short, the hashtable makes things
;; slower. We also need to balance memory usage.
- (let ((len (length list)))
+ (let ((len 0))
+ ;; Compute list length ourselves.
+ (dolist (item list)
+ (declare (ignore item))
+ (incf len))
(when (< len *min-list-length-for-hashtable*)
(return-from list-to-hashtable nil))
(let ((hashtable (make-hash-table :test hash-test :size len)))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/b100ecd403f9ce701532d38…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/b100ecd403f9ce701532d38…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl
Commits:
c3aa0678 by Raymond Toy at 2023-07-27T07:31:17-07:00
Fix typo.
- - - - -
1 changed file:
- src/code/list.lisp
Changes:
=====================================
src/code/list.lisp
=====================================
@@ -855,7 +855,7 @@
(cond (hashtable
;; list2 was placed in hash table.
(let ((res nil))
- (doli st (item list1)
+ (dolist (item list1)
(unless (nth-value 1 (gethash (apply-key key item) hashtable))
(push item res)))
res))
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c3aa0678c04d5197ed78376…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/c3aa0678c04d5197ed78376…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl
Commits:
96e66071 by Raymond Toy at 2023-07-26T18:59:10-07:00
Make +min-list-length-for-hashtable+ a defparameter again
Rename it using the `*foo*` convention too. It's super-convenient to
be able to set this for testing, which we do in the existing test
suite for this.
It's also convenient to be able to do this when doing timing tests so
we can compare what happens when the list version is used vs when the
hashtable is used.
- - - - -
7ab5d243 by Raymond Toy at 2023-07-26T19:00:59-07:00
Add some additional tests for set-difference
Add a test where a key is given to make sure that hashtable works
correctly with a key
Add a test where both a test and a test-not is given. This must
signal an error.
- - - - -
2 changed files:
- src/code/list.lisp
- tests/sets.lisp
Changes:
=====================================
src/code/list.lisp
=====================================
@@ -746,7 +746,7 @@
;; The minimum length of a list before we can use a hashtable. This
;; was determined experimentally.
-(defconstant +min-list-length-for-hashtable+
+(defparameter *min-list-length-for-hashtable*
15)
;; Convert a list to a hashtable. The hashtable does not handle
@@ -767,7 +767,7 @@
;; If the list is too short, the hashtable makes things
;; slower. We also need to balance memory usage.
(let ((len (length list)))
- (when (< len +min-list-length-for-hashtable+)
+ (when (< len *min-list-length-for-hashtable*)
(return-from list-to-hashtable nil))
(let ((hashtable (make-hash-table :test hash-test :size len)))
(dolist (item list)
@@ -855,7 +855,7 @@
(cond (hashtable
;; list2 was placed in hash table.
(let ((res nil))
- (dolist (item list1)
+ (doli st (item list1)
(unless (nth-value 1 (gethash (apply-key key item) hashtable))
(push item res)))
res))
=====================================
tests/sets.lisp
=====================================
@@ -72,3 +72,20 @@
(set-difference '("a" "b" "b" "C")
'("c" "D" "e" "f" "g" "h")
:test #'equalp))))
+
+;; Simple test that we handle a key correctly
+(define-test set-diff.hash-eql-with-key
+ (let ((lisp::*min-list-length-for-hashtable* 2))
+ (assert-equal '((3 "b") (2 "b"))
+ (set-difference '((1 "a") (2 "b") (3 "b"))
+ '((1 "a") (4 "c") (5 "d"))
+ :key #'first))))
+
+(define-test set-diff.test-and-test-not
+ (assert-error 'simple-error
+ (set-difference '(1 2)
+ '(3 4)
+ :test 'eql
+ :test-not 'eql)))
+
+
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/3fbae4d018b9bc6891effd…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/3fbae4d018b9bc6891effd…
You're receiving this email because of your account on gitlab.common-lisp.net.
Raymond Toy pushed to branch issue-240-set-diff-with-hash-table at cmucl / cmucl
Commits:
d6aae1fe by Raymond Toy at 2023-07-26T18:35:56-07:00
Revert change that converted cond to case
The use of `case` insted of `cond` didn't work as we naively
expected. Change it back to using `cond`.
- - - - -
3fbae4d0 by Raymond Toy at 2023-07-26T18:40:57-07:00
Fix args to list-to-hashtable
Originally, we had the args in the order `test`, `test-not`, and
`key`. We really should have `key`, `test`, and `test-not`. That's
how set-difference was calling `list-to-hashtable`, and it make more
sense for the args to be in this order.
- - - - -
1 changed file:
- src/code/list.lisp
Changes:
=====================================
src/code/list.lisp
=====================================
@@ -751,14 +751,17 @@
;; Convert a list to a hashtable. The hashtable does not handle
;; duplicated values in the list. Returns the hashtable.
-(defun list-to-hashtable (list test test-not key)
+(defun list-to-hashtable (list key test test-not)
;; Don't currently support test-not when converting a list to a hashtable
(unless test-not
- (let ((hash-test (case test
- ((#'eq 'eq) 'eq)
- ((#'eql 'eq) 'eql)
- ((#'equal 'equal) 'equal)
- ((#'equalp 'equalp) 'equalp))))
+ (let ((hash-test (let ((test-fn (if (and (symbolp test)
+ (fboundp test))
+ (fdefinition test)
+ test)))
+ (cond ((eql test-fn #'eq) 'eq)
+ ((eql test-fn #'eql) 'eql)
+ ((eql test-fn #'equal) 'equal)
+ ((eql test-fn #'equalp) 'equalp)))))
(unless hash-test
(return-from list-to-hashtable nil))
;; If the list is too short, the hashtable makes things
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/c09004a15331d191b5dcfe…
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/c09004a15331d191b5dcfe…
You're receiving this email because of your account on gitlab.common-lisp.net.