aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbouyssou2008-01-09 14:27:28 +0000
committerbouyssou2008-01-09 14:27:28 +0000
commitd953cc5c6e5bca46dbbd0c290ff53734b5aba9a4 (patch)
tree17475b7806ba6ce543fa5b4d72a4c36f0a2e8a55
parent18372150b8d1adc362f011650af699b640cd9a9c (diff)
downloadmtc-d953cc5c6e5bca46dbbd0c290ff53734b5aba9a4.zip
mtc-d953cc5c6e5bca46dbbd0c290ff53734b5aba9a4.tar.gz
mtc-d953cc5c6e5bca46dbbd0c290ff53734b5aba9a4.tar.bz2
mtc-d953cc5c6e5bca46dbbd0c290ff53734b5aba9a4.tar.xz
Amélioration des perfos de la methode mfind. On peut désormais accéder aux objets zinc via une table de hash. Attention tkdiff src/MTools.pm! il est impératif de supprimer et regénérer vos fichiers contenu dans les répertoires AUTOGEN.
-rw-r--r--src/MTools.pm21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/MTools.pm b/src/MTools.pm
index 61f57f6..250b092 100644
--- a/src/MTools.pm
+++ b/src/MTools.pm
@@ -542,9 +542,18 @@ sub rotate {
}
sub mfind {
- my ($obj, @params) = @_;
- my @tagged = $zinc -> find ('withtag', @params);
- my $ref = ref ($obj) eq '' ? $obj : $obj -> {instance};
+ my ($obj, $param) = @_;
+ if (ref ($obj) ne '' && defined $obj -> {children}) {
+ my $child = $obj -> {children} -> {$param};
+ if (defined $child) {
+ return $child;
+ }
+ }
+
+ if (ref ($obj) ne '') {
+ $obj = $obj -> {instance};
+ }
+ my @tagged = $zinc -> find ('withtag', ($param));
if (@tagged)
{
for (my $i = 0; $i < @tagged; $i++)
@@ -552,17 +561,17 @@ sub mfind {
my @ancestors = $zinc -> find ('ancestors', $tagged [$i]);
for (my $j = 0; $j < @ancestors; $j ++)
{
- if ($ancestors [$j] == $ref)
+ if ($ancestors [$j] == $obj)
{
return $tagged [$i];
}
}
}
- print "#### Warning : can't find any object matching with @params \n";
+ print "#### Warning : can't find any object matching with $param \n";
}
else
{
- print "#### Warning : can't find any object matching with @params \n";
+ print "#### Warning : can't find any object matching with $param \n";
}
return undef;
}