* Re: [nongnu] elpa/hyperdrive b5294b4354 4/4: Tidy: Use zerop instead of = 0 [not found] ` <20231013200057.2C7FCC09BC9@vcs2.savannah.gnu.org> @ 2023-10-13 22:12 ` Philip Kaludercic 2023-10-13 23:26 ` Joseph Turner 2023-10-14 21:33 ` Emanuel Berg 0 siblings, 2 replies; 5+ messages in thread From: Philip Kaludercic @ 2023-10-13 22:12 UTC (permalink / raw) To: emacs-devel; +Cc: Joseph Turner FWIW this doesn't matter that much, you can check the disassembly to see what is going on after byte compilation: (disassemble (byte-compile (lambda (a) (= a 0)))) (disassemble (byte-compile (lambda (a) (zerop a)))) ELPA Syncer <elpasync@gnu.org> writes: > branch: elpa/hyperdrive > commit b5294b43547379e87435c294670f4a23ac0739b7 > Author: Joseph Turner <joseph@ushin.org> > Commit: Joseph Turner <joseph@ushin.org> > > Tidy: Use zerop instead of = 0 > --- > hyperdrive-lib.el | 2 +- > hyperdrive.el | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el > index 1801fe0076..e2696160c9 100644 > --- a/hyperdrive-lib.el > +++ b/hyperdrive-lib.el > @@ -1033,7 +1033,7 @@ With universal prefix argument \\[universal-argument], prompt for entry." > With FORCE-PROMPT or when current hyperdrive does not match > PREDICATE, return a hyperdrive selected with completion. In this > case, when PREDICATE, only offer hyperdrives matching it." > - (when (= 0 (hash-table-count hyperdrive-hyperdrives)) > + (when (zerop (hash-table-count hyperdrive-hyperdrives)) > (hyperdrive-user-error "No known hyperdrives. Use `hyperdrive-new' to create a new one")) > (unless predicate > ;; cl-defun default value doesn't work when nil predicate value is passed in. > diff --git a/hyperdrive.el b/hyperdrive.el > index 824d33ba24..fcd2715b55 100644 > --- a/hyperdrive.el > +++ b/hyperdrive.el > @@ -827,7 +827,7 @@ The return value of this function is the retrieval buffer." > :help "Create a new hyperdrive"] > ("Drives" > :active (< 0 (hash-table-count hyperdrive-hyperdrives)) > - :label (if (= 0 (hash-table-count hyperdrive-hyperdrives)) > + :label (if (zerop (hash-table-count hyperdrive-hyperdrives)) > "Drives (empty)" > "Drives") > :filter (lambda (_) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [nongnu] elpa/hyperdrive b5294b4354 4/4: Tidy: Use zerop instead of = 0 2023-10-13 22:12 ` [nongnu] elpa/hyperdrive b5294b4354 4/4: Tidy: Use zerop instead of = 0 Philip Kaludercic @ 2023-10-13 23:26 ` Joseph Turner 2023-10-14 21:33 ` Emanuel Berg 1 sibling, 0 replies; 5+ messages in thread From: Joseph Turner @ 2023-10-13 23:26 UTC (permalink / raw) To: Philip Kaludercic; +Cc: emacs-devel Philip Kaludercic <philipk@posteo.net> writes: > FWIW this doesn't matter that much, you can check the disassembly to > see what is going on after byte compilation: > > (disassemble (byte-compile (lambda (a) (= a 0)))) > (disassemble (byte-compile (lambda (a) (zerop a)))) Thank you! I didn't know that :) > ELPA Syncer <elpasync@gnu.org> writes: > >> branch: elpa/hyperdrive >> commit b5294b43547379e87435c294670f4a23ac0739b7 >> Author: Joseph Turner <joseph@ushin.org> >> Commit: Joseph Turner <joseph@ushin.org> >> >> Tidy: Use zerop instead of = 0 >> --- >> hyperdrive-lib.el | 2 +- >> hyperdrive.el | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el >> index 1801fe0076..e2696160c9 100644 >> --- a/hyperdrive-lib.el >> +++ b/hyperdrive-lib.el >> @@ -1033,7 +1033,7 @@ With universal prefix argument \\[universal-argument], prompt for entry." >> With FORCE-PROMPT or when current hyperdrive does not match >> PREDICATE, return a hyperdrive selected with completion. In this >> case, when PREDICATE, only offer hyperdrives matching it." >> - (when (= 0 (hash-table-count hyperdrive-hyperdrives)) >> + (when (zerop (hash-table-count hyperdrive-hyperdrives)) >> (hyperdrive-user-error "No known hyperdrives. Use `hyperdrive-new' to create a new one")) >> (unless predicate >> ;; cl-defun default value doesn't work when nil predicate value is passed in. >> diff --git a/hyperdrive.el b/hyperdrive.el >> index 824d33ba24..fcd2715b55 100644 >> --- a/hyperdrive.el >> +++ b/hyperdrive.el >> @@ -827,7 +827,7 @@ The return value of this function is the retrieval buffer." >> :help "Create a new hyperdrive"] >> ("Drives" >> :active (< 0 (hash-table-count hyperdrive-hyperdrives)) >> - :label (if (= 0 (hash-table-count hyperdrive-hyperdrives)) >> + :label (if (zerop (hash-table-count hyperdrive-hyperdrives)) >> "Drives (empty)" >> "Drives") >> :filter (lambda (_) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [nongnu] elpa/hyperdrive b5294b4354 4/4: Tidy: Use zerop instead of = 0 2023-10-13 22:12 ` [nongnu] elpa/hyperdrive b5294b4354 4/4: Tidy: Use zerop instead of = 0 Philip Kaludercic 2023-10-13 23:26 ` Joseph Turner @ 2023-10-14 21:33 ` Emanuel Berg 2023-10-15 9:17 ` Philip Kaludercic 1 sibling, 1 reply; 5+ messages in thread From: Emanuel Berg @ 2023-10-14 21:33 UTC (permalink / raw) To: emacs-devel Philip Kaludercic wrote: > FWIW this doesn't matter that much, you can check the > disassembly to see what is going on after byte compilation: > > (disassemble (byte-compile (lambda (a) (= a 0)))) byte code: args: (a) 0 varref a 1 constant 0 2 eqlsign 3 return > (disassemble (byte-compile (lambda (a) (zerop a)))) byte code: args: (a) 0 varref a 1 constant 0 2 eqlsign 3 return They are identical, is that what you mean it doesn't matter that much? To use `zerop' is maybe more classy - the attitude being to minimize everything as much as possible - as it is a unary function (1 argument) while `=', as it is used here, is binary (2 arguments). BTW = can be used unary as well, then it always returns t - even for nil. (= nil) ; t But why do that? As it is more classy to just use t :) -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [nongnu] elpa/hyperdrive b5294b4354 4/4: Tidy: Use zerop instead of = 0 2023-10-14 21:33 ` Emanuel Berg @ 2023-10-15 9:17 ` Philip Kaludercic 2023-10-15 9:39 ` Emanuel Berg 0 siblings, 1 reply; 5+ messages in thread From: Philip Kaludercic @ 2023-10-15 9:17 UTC (permalink / raw) To: emacs-devel You dropped me out of the CC's. Emanuel Berg <incal@dataswamp.org> writes: > Philip Kaludercic wrote: > >> FWIW this doesn't matter that much, you can check the >> disassembly to see what is going on after byte compilation: >> >> (disassemble (byte-compile (lambda (a) (= a 0)))) > > byte code: > args: (a) > 0 varref a > 1 constant 0 > 2 eqlsign > 3 return > >> (disassemble (byte-compile (lambda (a) (zerop a)))) > > byte code: > args: (a) > 0 varref a > 1 constant 0 > 2 eqlsign > 3 return > > They are identical, is that what you mean it doesn't matter > that much? My comment was just to indicate that there is no need to change from one to the other, e.g. for performance reasons (which would have been my intuition), but also as a reminder to check the result of byte compilation. > To use `zerop' is maybe more classy - the attitude being to > minimize everything as much as possible - as it is a unary > function (1 argument) while `=', as it is used here, is binary > (2 arguments). > > BTW = can be used unary as well, then it always returns t - > even for nil. (= nil) ; t > > But why do that? As it is more classy to just use t :) I guess? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [nongnu] elpa/hyperdrive b5294b4354 4/4: Tidy: Use zerop instead of = 0 2023-10-15 9:17 ` Philip Kaludercic @ 2023-10-15 9:39 ` Emanuel Berg 0 siblings, 0 replies; 5+ messages in thread From: Emanuel Berg @ 2023-10-15 9:39 UTC (permalink / raw) To: emacs-devel Philip Kaludercic wrote: >> They are identical, is that what you mean it doesn't matter >> that much? > > My comment was just to indicate that there is no need to > change from one to the other, e.g. for performance reasons > (which would have been my intuition), but also as a reminder > to check the result of byte compilation. Performance? :O No, I'm pretty sure the OP mean `zerop' is more specific (and has less arguments as a consequence) so the code looks better using it. It is like using (car some-list) instead of (nth 0 some-list) ... -- underground experts united https://dataswamp.org/~incal ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-15 9:39 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <169722725606.27637.3820182151024041420@vcs2.savannah.gnu.org> [not found] ` <20231013200057.2C7FCC09BC9@vcs2.savannah.gnu.org> 2023-10-13 22:12 ` [nongnu] elpa/hyperdrive b5294b4354 4/4: Tidy: Use zerop instead of = 0 Philip Kaludercic 2023-10-13 23:26 ` Joseph Turner 2023-10-14 21:33 ` Emanuel Berg 2023-10-15 9:17 ` Philip Kaludercic 2023-10-15 9:39 ` Emanuel Berg
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.