From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73533: [PATCH] Rewrite speedbar expansion for all descendants Date: Sun, 29 Sep 2024 07:46:08 +0300 Message-ID: <86a5fr5apb.fsf@gnu.org> References: <87y13blhu1.fsf@ice9.digital> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7643"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73533@debbugs.gnu.org To: Morgan Willcock Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 29 06:46:53 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sulpd-0001rm-8z for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Sep 2024 06:46:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sulpK-0004WD-9F; Sun, 29 Sep 2024 00:46:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sulpI-0004Vp-D8 for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2024 00:46:32 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sulpI-0005eJ-3w for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2024 00:46:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=JB/dWYtCR0N1LRXjD1GkBCNChvP0s8lC3++1IE6BO78=; b=HUDAvWGG1xfgbzkeq9zy1S/2TU3aY5Bx88W2jjlZPYHxoc0WQ3tktZHWSBk/+JgoGcK89tQaogxBNKpIAr7ZuaKk66rZ/Ey+L6EiB9iL3heOzDDV8AaltnvxLEugMgKCGQLCXVxFmw9FaEK8FEktVecLe+H55nUgtl8QqaH2bS/qElg7ZafMWF/OkCIzHeJcdjhwxluy3scDKLrWmGXoDM2uNQ7QlqIXsMHORQxxk2ckuTUvuqNqsy4GP2aRmJVKk7rjZONmZ3jAahDGJpdG3v14VbuZ3r+LU8jBK46iPcvy7A+XuxtAJwgtXAwCSZw1jnENJzS6jUeRXeCt3Qoitg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sulpm-0003yG-9u for bug-gnu-emacs@gnu.org; Sun, 29 Sep 2024 00:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Sep 2024 04:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73533 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73533-submit@debbugs.gnu.org id=B73533.172758521115211 (code B ref 73533); Sun, 29 Sep 2024 04:47:02 +0000 Original-Received: (at 73533) by debbugs.gnu.org; 29 Sep 2024 04:46:51 +0000 Original-Received: from localhost ([127.0.0.1]:58927 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sulpb-0003xG-6J for submit@debbugs.gnu.org; Sun, 29 Sep 2024 00:46:51 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sulpZ-0003wz-Fg for 73533@debbugs.gnu.org; Sun, 29 Sep 2024 00:46:50 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sulox-0005cY-1k; Sun, 29 Sep 2024 00:46:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=JB/dWYtCR0N1LRXjD1GkBCNChvP0s8lC3++1IE6BO78=; b=QNwQ/g3P3gB8 rbgLlZm9/st9H/XNyoBwYJYti0oSUNHS0bCeOz6OT7QP0yn2kaAIS159Wd1cJdyjWtjlHGGqAWwRX yd15W2F9o5pHQGg0EfHlabwcVbF2vF9N11rraDQYtSpxmbZ1tjO14DLFNK1RxrmfW7AWM1k4hEByS War8AD9WIswvHvIlB7bz4b17YX9xXHAeAEsT44lM80zmw+ByLeP4Cw0Oh9kMjnr3IcJjLchOJuvp7 OBVV2DWFrog5TGxm6yPPuVJ8Zmo1cD52wE0eazKXCKQvfUr7kdIwvQnuglM9me6eS4/6QOHfI9s6X DbjPBxCpI9qV4/Ao0rLG/A==; In-Reply-To: <87y13blhu1.fsf@ice9.digital> (message from Morgan Willcock on Sat, 28 Sep 2024 20:05:26 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292613 Archived-At: > From: Morgan Willcock > Date: Sat, 28 Sep 2024 20:05:26 +0100 > > Attached is a patch which rewrites 'speedbar-expand-line-descendants'. > > The previous version could get into an infinite loop by reaching the > maximum recursion depth, although in practice the slow speed meant that > most people would probably abort the operation before reaching that > point. > > The majority of the slowdown was because the motion commands being used > were the variants which looked up information for every entry, displayed > the information as a message, and adjusted the cursor position. The > messages were not readable because of being continually overwritten. > > Here is a way to demonstrate that stack depth was increasing for items > at the same level, that the messages were not readable, and how slow the > whole process was: > > rm -rf /tmp/project > mkdir /tmp/project > for i in $(seq 1 50); do echo "(defun fun-$i ())" >> /tmp/project/file1.el; done > for i in $(seq 1 50); do echo "(defun fun-$i ())" >> /tmp/project/file2.el; done > emacs -Q \ > --eval="(find-file \"/tmp/project/file1.el\")" \ > --eval "(speedbar-get-focus)" \ > --eval "(profiler-start 'cpu)" \ > --eval "(speedbar-expand-line-descendants)" \ > --eval "(profiler-stop)" \ > --eval "(profiler-report)" > > ...that should expand every entry in file1.el and not touch the entries > in file2.el. > > The replacement function is significantly faster. Messages are only > used to indicate that the function is running and when it is finished - > the result is similar to manually clicking every node open. Thanks. Unfortunately, speedbar doesn't have a test suite, so I would like to ask how you tested this rewrite, and whether we could have some tests for this added to the test suite. Regardless, it would be good to have both old and the new code annotated with explanations of what each non-trivial line does, to allow independent verification of the correctness of the rewrite by people who are not familiar with speedbar code and don't immediately understand the effects of a call to speedbar-naxt or speedbar-restricted-move. Also, this comment in the old code bothers me: > - ;; Now, inside the area expanded here, expand all subnodes of > - ;; the same descendant type. What does it mean by "the same descendant type", and how does the old and the new code make sure they expand only those descendants?