Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
gambas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Custom issue tracker
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
3
Snippets
Groups
Projects
Show more breadcrumbs
Gambas
gambas
Commits
91cf8ef3
Commit
91cf8ef3
authored
4 years ago
by
gambas
Browse files
Options
Downloads
Patches
Plain Diff
Min() and Max() are now faster.
[INTERPRETER] * OPT: Min() and Max() are now faster.
parent
157c59f0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#244942444
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main/gbx/gbx_subr_test.c
+92
-45
92 additions, 45 deletions
main/gbx/gbx_subr_test.c
with
92 additions
and
45 deletions
main/gbx/gbx_subr_test.c
+
92
−
45
View file @
91cf8ef3
...
...
@@ -867,85 +867,130 @@ void SUBR_is(ushort code)
void
SUBR_min_max
(
ushort
code
)
{
static
void
*
jump
[]
=
{
&&
__VARIANT
,
&&
__BOOLEAN
,
&&
__BYTE
,
&&
__SHORT
,
&&
__INTEGER
,
&&
__LONG
,
&&
__FLOAT
,
&&
__FLOAT
,
&&
__DATE
&&
__VARIANT
,
&&
__MIN_BOOLEAN
,
&&
__MIN_BYTE
,
&&
__MIN_SHORT
,
&&
__MIN_INTEGER
,
&&
__MIN_LONG
,
&&
__MIN_SINGLE
,
&&
__MIN_FLOAT
,
&&
__MIN_DATE
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
&&
__VARIANT
,
&&
__MAX_BOOLEAN
,
&&
__MAX_BYTE
,
&&
__MAX_SHORT
,
&&
__MAX_INTEGER
,
&&
__MAX_LONG
,
&&
__MAX_SINGLE
,
&&
__MAX_FLOAT
,
&&
__MAX_DATE
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
};
TYPE
type
;
VALUE
*
P1
,
*
P2
;
void
*
jump_end
;
bool
is_max
;
P1
=
SP
-
2
;
P2
=
P1
+
1
;
jump_end
=
&&
__END
;
type
=
code
&
0x0F
;
is_max
=
((
code
>>
8
)
==
CODE_MAX
);
goto
*
jump
[
type
];
goto
*
jump
[
code
&
0x1F
];
__BOOLEAN:
__BYTE:
__SHORT:
__INTEGER:
__
MIN_
BOOLEAN:
__
MIN_
BYTE:
__
MIN_
SHORT:
__
MIN_
INTEGER:
P1
->
type
=
type
;
if
(
is_max
)
{
if
(
P2
->
_integer
.
value
>
P1
->
_integer
.
value
)
P1
->
_integer
.
value
=
P2
->
_integer
.
value
;
}
else
{
if
(
P2
->
_integer
.
value
<
P1
->
_integer
.
value
)
P1
->
_integer
.
value
=
P2
->
_integer
.
value
;
}
goto
*
jump_end
;
__LONG:
__MAX_BOOLEAN:
__MAX_BYTE:
__MAX_SHORT:
__MAX_INTEGER:
P1
->
type
=
type
;
if
(
P2
->
_integer
.
value
>
P1
->
_integer
.
value
)
P1
->
_integer
.
value
=
P2
->
_integer
.
value
;
goto
*
jump_end
;
__MIN_LONG:
VALUE_conv
(
P1
,
T_LONG
);
VALUE_conv
(
P2
,
T_LONG
);
if
(
is_max
)
{
if
(
P2
->
_long
.
value
>
P1
->
_long
.
value
)
P1
->
_long
.
value
=
P2
->
_long
.
value
;
}
else
{
if
(
P2
->
_long
.
value
<
P1
->
_long
.
value
)
P1
->
_long
.
value
=
P2
->
_long
.
value
;
}
goto
*
jump_end
;
__FLOAT:
__MAX_LONG:
VALUE_conv
(
P1
,
T_LONG
);
VALUE_conv
(
P2
,
T_LONG
);
if
(
P2
->
_long
.
value
>
P1
->
_long
.
value
)
P1
->
_long
.
value
=
P2
->
_long
.
value
;
goto
*
jump_end
;
__MIN_SINGLE:
VALUE_conv
(
P1
,
T_SINGLE
);
VALUE_conv
(
P2
,
T_SINGLE
);
if
(
P2
->
_single
.
value
<
P1
->
_single
.
value
)
P1
->
_single
.
value
=
P2
->
_single
.
value
;
goto
*
jump_end
;
__MAX_SINGLE:
VALUE_conv
(
P1
,
T_SINGLE
);
VALUE_conv
(
P2
,
T_SINGLE
);
if
(
P2
->
_single
.
value
>
P1
->
_single
.
value
)
P1
->
_single
.
value
=
P2
->
_single
.
value
;
goto
*
jump_end
;
__MIN_FLOAT:
VALUE_conv_float
(
P1
);
VALUE_conv_float
(
P2
);
if
(
P2
->
_float
.
value
<
P1
->
_float
.
value
)
P1
->
_float
.
value
=
P2
->
_float
.
value
;
goto
*
jump_end
;
__MAX_FLOAT:
VALUE_conv_float
(
P1
);
VALUE_conv_float
(
P2
);
if
(
is_max
)
{
if
(
P2
->
_float
.
value
>
P1
->
_float
.
value
)
P1
->
_float
.
value
=
P2
->
_float
.
value
;
}
else
goto
*
jump_end
;
__MIN_DATE:
VALUE_conv
(
P1
,
T_DATE
);
VALUE_conv
(
P2
,
T_DATE
);
if
(
DATE_comp_value
(
P1
,
P2
)
==
1
)
{
if
(
P2
->
_float
.
valu
e
<
P
1
->
_
float
.
value
)
P1
->
_
float
.
value
=
P2
->
_float
.
valu
e
;
P1
->
_date
.
dat
e
=
P
2
->
_
date
.
date
;
P1
->
_
date
.
time
=
P2
->
_date
.
tim
e
;
}
goto
*
jump_end
;
__DATE:
__
MAX_
DATE:
VALUE_conv
(
P1
,
T_DATE
);
VALUE_conv
(
P2
,
T_DATE
);
if
(
DATE_comp_value
(
P1
,
P2
)
==
(
is_max
?
-
1
:
1
))
*
P1
=
*
P2
;
if
(
DATE_comp_value
(
P1
,
P2
)
==
-
1
)
{
P1
->
_date
.
date
=
P2
->
_date
.
date
;
P1
->
_date
.
time
=
P2
->
_date
.
time
;
}
goto
*
jump_end
;
...
...
@@ -955,8 +1000,9 @@ __VARIANT:
if
(
TYPE_is_number_date
(
type
))
{
*
PC
|=
type
;
goto
*
jump
[
type
];
code
=
type
+
((
code
>>
8
)
==
CODE_MAX
)
*
16
;
*
PC
|=
code
;
goto
*
jump
[
code
];
}
if
(
TYPE_is_variant
(
P1
->
type
))
...
...
@@ -970,7 +1016,8 @@ __VARIANT:
if
(
TYPE_is_number_date
(
type
))
{
jump_end
=
&&
__VARIANT_END
;
goto
*
jump
[
type
];
code
=
type
+
((
code
>>
8
)
==
CODE_MAX
)
*
16
;
goto
*
jump
[
code
];
}
goto
__ERROR
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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