emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Anton Latukha <anton@latukha.com>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] org: org-get-priority: reduce `not`, deduplicate magic `(* 1000 ..)` operation
Date: Sun, 29 Sep 2019 03:34:54 +0300	[thread overview]
Message-ID: <10577751569717294@sas1-a0d9133b67ec.qloud-c.yandex.net> (raw)

[-- Attachment #1: Type: text/html, Size: 571 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-org-get-priority-rm-reduce-negation-operation.patch --]
[-- Type: text/x-diff; name="0001-org-org-get-priority-rm-reduce-negation-operation.patch", Size: 1073 bytes --]

From afb204303a388f2644a535dccef6f603d3519ead Mon Sep 17 00:00:00 2001
From: Anton-Latukha <anton.latukha@gmail.com>
Date: Sun, 29 Sep 2019 03:08:24 +0300
Subject: [PATCH 1/2] org: org-get-priority: rm: reduce negation operation

* org (org-get-priority): reducing bool negation operation by
switching if cases
---
 lisp/org.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 450d16083..72408f49f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11679,10 +11679,10 @@ and by additional input from the age of a schedules or deadline entry."
   (save-match-data
     (if (functionp org-get-priority-function)
 	(funcall org-get-priority-function)
-      (if (not (string-match org-priority-regexp s))
-	  (* 1000 (- org-lowest-priority org-default-priority))
+      (if (string-match org-priority-regexp s)
 	(* 1000 (- org-lowest-priority
-		   (string-to-char (match-string 2 s))))))))
+		   (string-to-char (match-string 2 s))))
+	(* 1000 (- org-lowest-priority org-default-priority))))))
 
 ;;;; Tags
 
-- 
2.23.0


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-org-org-get-priority-push-same-magic-1000-.-op-outsi.patch --]
[-- Type: text/x-diff; name="0002-org-org-get-priority-push-same-magic-1000-.-op-outsi.patch", Size: 1139 bytes --]

From c1e5afed098133103c0d7c44db4da4a939aa6431 Mon Sep 17 00:00:00 2001
From: Anton-Latukha <anton.latukha@gmail.com>
Date: Sun, 29 Sep 2019 03:10:25 +0300
Subject: [PATCH 2/2] org: org-get-priority: push same magic (* 1000 .. ) op
 outside of if

* org (org-get-priority): Push the same magic (* 1000 ..) operation
outside applying it to if overall.
---
 lisp/org.el | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 72408f49f..8aabce5f4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11679,10 +11679,11 @@ and by additional input from the age of a schedules or deadline entry."
   (save-match-data
     (if (functionp org-get-priority-function)
 	(funcall org-get-priority-function)
-      (if (string-match org-priority-regexp s)
-	(* 1000 (- org-lowest-priority
-		   (string-to-char (match-string 2 s))))
-	(* 1000 (- org-lowest-priority org-default-priority))))))
+      (* 1000
+	 (if (string-match org-priority-regexp s)
+	     (- org-lowest-priority
+		(string-to-char (match-string 2 s)))
+	   (- org-lowest-priority org-default-priority))))))
 
 ;;;; Tags
 
-- 
2.23.0


             reply	other threads:[~2019-09-29  0:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-29  0:34 Anton Latukha [this message]
2019-10-08  9:25 ` [PATCH] org: org-get-priority: reduce `not`, deduplicate magic `(* 1000 ..)` operation Nicolas Goaziou
2019-10-08 21:28   ` Anton Latukha
2019-10-08 22:23     ` Anton Latukha
2019-10-09 19:33       ` Adam Porter
2019-10-10  2:25         ` Samuel Wales
2019-10-10 12:47       ` Nicolas Goaziou
2019-10-10 14:24         ` Anton Latukha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10577751569717294@sas1-a0d9133b67ec.qloud-c.yandex.net \
    --to=anton@latukha.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).