From a43ab55b66deb5a8414fa6d9ead98e6a1d48dded Mon Sep 17 00:00:00 2001 From: freesource Date: Tue, 28 Aug 2001 04:18:55 +0000 Subject: [PATCH] This makes the insensitive search more effecient by not continuously invocating tr///. --- BootRoot/YardBox.pm | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/BootRoot/YardBox.pm b/BootRoot/YardBox.pm index 29189fd..96a7870 100644 --- a/BootRoot/YardBox.pm +++ b/BootRoot/YardBox.pm @@ -1173,6 +1173,8 @@ sub search { # Search button my ($keywords, $old_keywords, $offset); + my ($tmp_ct, $tmp_k); + my $submit_b = button(0,1,3,4,"Search",$table_search); $search1->signal_connect("key_press_event", sub { my $event = pop @_; @@ -1185,16 +1187,19 @@ sub search { $submit_b->grab_default; $submit_b->signal_connect( "clicked", sub { my $keywords = $search1->get_text(); - + # rindex if ($search_backwards->active) { if (!$offset) { if(!$case_sensitive->active) { - my ($tmp_ct, $tmp_k); - ($tmp_ct = $changed_text_from_template) =~ tr/A-Z/a-z/; - ($tmp_k = $keywords) =~ tr/A-Z/a-z/; + if (!$tmp_ct && !$tmp_k) { + ($tmp_ct = $changed_text_from_template) =~ + tr/A-Z/a-z/; + ($tmp_k = $keywords) =~ tr/A-Z/a-z/; + } $offset = rindex($tmp_ct, $tmp_k); + } else { $offset = rindex($changed_text_from_template, @@ -1212,9 +1217,11 @@ sub search { $offset = $offset - 1; if(!$case_sensitive->active) { - my ($tmp_ct, $tmp_k); - ($tmp_ct = $changed_text_from_template) =~ tr/A-Z/a-z/; - ($tmp_k = $keywords) =~ tr/A-Z/a-z/; + if (!$tmp_ct && !$tmp_k) { + ($tmp_ct = $changed_text_from_template) =~ + tr/A-Z/a-z/; + ($tmp_k = $keywords) =~ tr/A-Z/a-z/; + } $offset = rindex($tmp_ct, $tmp_k, $offset); } else { @@ -1240,9 +1247,11 @@ sub search { else { if (!$offset) { if(!$case_sensitive->active) { - my ($tmp_ct, $tmp_k); - ($tmp_ct = $changed_text_from_template) =~ tr/A-Z/a-z/; - ($tmp_k = $keywords) =~ tr/A-Z/a-z/; + if (!$tmp_ct && !$tmp_k) { + ($tmp_ct = $changed_text_from_template) =~ + tr/A-Z/a-z/; + ($tmp_k = $keywords) =~ tr/A-Z/a-z/; + } $offset = index($tmp_ct, $tmp_k); } else { @@ -1265,9 +1274,11 @@ sub search { $offset = $offset + 1; if(!$case_sensitive->active) { - my ($tmp_ct, $tmp_k); - ($tmp_ct = $changed_text_from_template) =~ tr/A-Z/a-z/; - ($tmp_k = $keywords) =~ tr/A-Z/a-z/; + if (!$tmp_ct && !$tmp_k) { + ($tmp_ct = $changed_text_from_template) =~ + tr/A-Z/a-z/; + ($tmp_k = $keywords) =~ tr/A-Z/a-z/; + } $offset = index($tmp_ct, $tmp_k, $offset); } else {