Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
6ec062e1
Commit
6ec062e1
authored
21 years ago
by
Graham McVicker
Browse files
Options
Downloads
Patches
Plain Diff
made rearrange method a lot faster (but uglier)
parent
b4ab841b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Bio/EnsEMBL/Utils/Argument.pm
+9
-32
9 additions, 32 deletions
modules/Bio/EnsEMBL/Utils/Argument.pm
with
9 additions
and
32 deletions
modules/Bio/EnsEMBL/Utils/Argument.pm
+
9
−
32
View file @
6ec062e1
...
...
@@ -89,10 +89,9 @@ use vars qw(@ISA @EXPORT_OK);
: @param = (-name=>'me', -color=>'blue');
: @param = (-NAME=>'me', -COLOR=>'blue');
: @param = (-Name=>'me', -Color=>'blue');
: @param = ('me', 'blue');
: A leading hyphenated argument is used by this function to
: indicate that named parameters are being used.
: Therefore,
the
('me', 'blue') list will be returned as-is.
: Therefore,
a
('me', 'blue') list will be returned as-is.
:
: Note that Perl will confuse unquoted, hyphenated tags as
: function calls if there is a function of the same name
...
...
@@ -116,47 +115,25 @@ use vars qw(@ISA @EXPORT_OK);
sub
rearrange
{
my
(
$order
,
@param
)
=
@_
;
return
unless
@param
;
my
$order
=
shift
;
# If we've got parameters, we need to check to see whether
# they are named or simply listed. If they are listed, we
# can just return them.
return
@param
unless
(
defined
(
$param
[
0
])
&&
$param
[
0
]
=~
/^-/
);
# Now we've got to do some work on the named parameters.
# The next few lines strip out the '-' characters which
# preceed the keys, and capitalizes them.
my
$i
;
for
(
$i
=
0
;
$i
<
@param
;
$i
+=
2
)
{
$param
[
$i
]
=~
s/^\-//
;
$param
[
$i
]
=~
tr/a-z/A-Z/
;
}
# can just return them.
return
@
_
unless
(
@
_
&&
$_
[
0
]
&&
substr
(
$_
[
0
],
0
,
1
)
eq
'
-
');
# Now we'll convert the @params variable into an associative array.
local
(
$^W
)
=
0
;
# prevent "odd number of elements" warning with -w.
my
(
%param
)
=
@param
;
# Convert all of the parameter names to uppercase, and create a
# hash with parameter names as keys, and parameter values as values
my
$i
=
0
;
my
(
%param
)
=
map
{
if
(
$i
)
{
$i
--
;
$_
;
}
else
{
$i
++
;
uc
(
$_
);
}}
@_
;
my
(
@return_array
);
# What we intend to do is loop through the @{$order} variable,
# and for each value, we use that as a key into our associative
# array, pushing the value at that key onto our return array.
my
(
$key
);
foreach
$key
(
@
{
$order
})
{
$key
=
uc
(
$key
);
my
(
$value
)
=
$param
{
$key
};
delete
$param
{
$key
};
push
(
@return_array
,
$value
);
}
return
(
@return_array
);
return
map
{
$param
{
uc
("
-
$_
")}
||
$param
{
uc
(
$_
)}}
@$order
;
}
1
;
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment