Revert: "Change: (olp, olps) Optimize multiple args with heading query"

This reverts commit 2d07cb0822.

See issue #160.  Thanks to @yantar92 for reporting.
This commit is contained in:
Adam Porter 2020-12-03 22:14:31 -06:00
parent b62896a583
commit 1389ccb46b
3 changed files with 29 additions and 49 deletions

View file

@ -521,7 +521,6 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
*Changed* *Changed*
+ Helm support (including the command =helm-org-ql=) has been moved to a separate package, =helm-org-ql=. + Helm support (including the command =helm-org-ql=) has been moved to a separate package, =helm-org-ql=.
+ Predicates ~outline-path~ and ~outline-path-segment~, when called with multiple arguments, optimize to a query like ~(and (heading LAST-OLP-ARG) (olp OTHER-OLP-ARGS))~, which is much faster.
*Internal* *Internal*
+ Predicates are now defined more cleanly with a macro (=org-ql-defpred=) that consolidates functionality related to each predicate. This will also allow users to more easily define custom predicates. + Predicates are now defined more cleanly with a macro (=org-ql-defpred=) that consolidates functionality related to each predicate. This will also allow users to more easily define custom predicates.

View file

@ -1170,17 +1170,9 @@ the following queries:
(olp \"Food\" \"Fruits\") (olp \"Food\" \"Fruits\")
(olp \"Fruits\" \"Grapes\") (olp \"Fruits\" \"Grapes\")
(olp \"Food\" \"Grapes\")" (olp \"Food\" \"Grapes\")"
;; FIXME: Stop regexp quoting when the (heading) predicate is changed to take a non-regexp string. :normalizers ((`(,predicate-names . ,strings)
:normalizers ((`(,predicate-names ,string) ;; Regexp quote headings.
;; Equivalent to (heading string), which is much faster. `(outline-path ,@(mapcar #'regexp-quote strings))))
`(heading ,(regexp-quote string)))
(`(,predicate-names . ,strings)
;; Rewrite query to use (heading) with the last string
;; and (olp) for the rest, which is much faster.
(let ((last (car (last strings)))
(rest (butlast strings)))
`(and (heading ,(regexp-quote last))
(outline-path ,@(mapcar #'regexp-quote rest))))))
:body (let ((entry-olp (org-ql--value-at (point) #'org-ql--outline-path))) :body (let ((entry-olp (org-ql--value-at (point) #'org-ql--outline-path)))
(cl-loop for h in regexps (cl-loop for h in regexps
always (cl-member h entry-olp :test #'string-match)))) always (cl-member h entry-olp :test #'string-match))))
@ -1203,17 +1195,9 @@ contiguous segment of the outline path:
(olp \"Food\" \"Grape\")" (olp \"Food\" \"Grape\")"
;; MAYBE: Allow anchored matching. ;; MAYBE: Allow anchored matching.
;; FIXME: Stop regexp quoting when the (heading) predicate is changed to take a non-regexp string. :normalizers ((`(,(or 'outline-path-segment 'olps) . ,strings)
:normalizers ((`(,predicate-names ,string) ;; Regexp quote headings.
;; Equivalent to (heading string), which is much faster. `(outline-path-segment ,@(mapcar #'regexp-quote strings))))
`(heading ,(regexp-quote string)))
(`(,predicate-names . ,strings)
;; Rewrite query to use (heading) with the last string
;; and (olp) for the rest, which is much faster.
(let ((last (car (last strings)))
(rest (butlast strings)))
`(and (heading ,(regexp-quote last))
(outline-path-segment ,@(mapcar #'regexp-quote rest))))))
:body (org-ql--infix-p regexps (org-ql--value-at (point) #'org-ql--outline-path))) :body (org-ql--infix-p regexps (org-ql--value-at (point) #'org-ql--outline-path)))
(org-ql-defpred path (&rest regexps) (org-ql-defpred path (&rest regexps)

View file

@ -966,9 +966,6 @@ File: README.info, Node: 06-pre, Next: 05, Up: Changelog
*Changed* *Changed*
• Helm support (including the command helm-org-ql) has been moved to • Helm support (including the command helm-org-ql) has been moved to
a separate package, helm-org-ql. a separate package, helm-org-ql.
• Predicates outline-path and outline-path-segment, when called
with multiple arguments, optimize to a query like (and (heading
LAST-OLP-ARG) (olp OTHER-OLP-ARGS)), which is much faster.
*Internal* *Internal*
• Predicates are now defined more cleanly with a macro • Predicates are now defined more cleanly with a macro
@ -1491,29 +1488,29 @@ Node: Links33872
Node: Tips34559 Node: Tips34559
Node: Changelog34877 Node: Changelog34877
Node: 06-pre35573 Node: 06-pre35573
Node: 0536416 Node: 0536196
Node: 04937893 Node: 04937673
Node: 04838167 Node: 04837947
Node: 04738514 Node: 04738294
Node: 04638909 Node: 04638689
Node: 04539309 Node: 04539089
Node: 04439668 Node: 04439448
Node: 04340025 Node: 04339805
Node: 04240220 Node: 04240000
Node: 04140381 Node: 04140161
Node: 0440622 Node: 0440402
Node: 03244555 Node: 03244335
Node: 03144934 Node: 03144714
Node: 0345131 Node: 0344911
Node: 02348106 Node: 02347886
Node: 02248334 Node: 02248114
Node: 02148602 Node: 02148382
Node: 0248801 Node: 0248581
Node: 0152836 Node: 0152616
Node: Notes52937 Node: Notes52717
Node: Comparison with Org Agenda searches53099 Node: Comparison with Org Agenda searches52879
Node: org-sidebar53971 Node: org-sidebar53751
Node: License54250 Node: License54030
 
End Tag Table End Tag Table