Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
2d404b3a
There was an error fetching the commit references. Please try again later.
Commit
2d404b3a
authored
14 years ago
by
Adam Wardynski
Browse files
Options
Downloads
Patches
Plain Diff
Reshuffling code a bit for some optimization.
parent
27614982
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libwccl/ops/functions/bool/iteration.cpp
+26
-22
26 additions, 22 deletions
libwccl/ops/functions/bool/iteration.cpp
with
26 additions
and
22 deletions
libwccl/ops/functions/bool/iteration.cpp
+
26
−
22
View file @
2d404b3a
...
@@ -28,30 +28,34 @@ std::string Iteration::to_raw_string() const
...
@@ -28,30 +28,34 @@ std::string Iteration::to_raw_string() const
Iteration
::
BaseRetValPtr
Iteration
::
apply_internal
(
const
FunExecContext
&
context
)
const
Iteration
::
BaseRetValPtr
Iteration
::
apply_internal
(
const
FunExecContext
&
context
)
const
{
{
const
boost
::
shared_ptr
<
const
Position
>&
range_begin
=
left_pos_expr_
->
apply
(
context
);
const
boost
::
shared_ptr
<
Position
>&
iter_var
=
const
boost
::
shared_ptr
<
const
Position
>&
range_end
=
right_pos_expr_
->
apply
(
context
);
context
.
variables
()
->
get_fast
(
iter_var_acc_
);
const
boost
::
shared_ptr
<
Position
>&
iter_var
=
context
.
variables
()
->
get_fast
(
iter_var_acc_
);
const
SentenceContext
&
sc
=
context
.
sentence_context
();
const
SentenceContext
&
sc
=
context
.
sentence_context
();
// Get absolute values for left and right extremes of the range
int
left
=
sc
.
get_abs_position
(
*
range_begin
);
int
right
=
sc
.
get_abs_position
(
*
range_end
);
// Proceed only if range extremes are not "nowhere".
// Proceed only if range extremes are not "nowhere".
if
(
left
!=
Position
::
Nowhere
&&
right
!=
Position
::
Nowhere
)
{
const
boost
::
shared_ptr
<
const
Position
>&
range_left
=
// Trim range to sentence boundaries
left_pos_expr_
->
apply
(
context
);
if
(
left
<
0
)
{
if
(
range_left
->
get_value
()
!=
Position
::
Nowhere
)
{
left
=
0
;
const
boost
::
shared_ptr
<
const
Position
>&
range_right
=
}
right_pos_expr_
->
apply
(
context
);
if
(
right
>=
sc
.
size
())
{
if
(
range_right
->
get_value
()
!=
Position
::
Nowhere
)
{
right
=
sc
.
size
()
-
1
;
// Get absolute values for left and right extremes of the range.
}
int
right
=
sc
.
get_abs_position
(
*
range_end
);
// Proceed only if range isn't empty
int
left
=
sc
.
get_abs_position
(
*
range_begin
);
if
(
left
<=
right
)
{
// Trim range to sentence boundaries
// Change range from absolute to relative and iterate
if
(
left
<
0
)
{
left
-=
sc
.
get_position
();
left
=
0
;
right
-=
sc
.
get_position
();
}
if
(
iterate
(
left
,
right
,
*
iter_var
,
context
))
{
if
(
right
>=
sc
.
size
())
{
return
Predicate
::
True
(
context
);
right
=
sc
.
size
()
-
1
;
}
// Proceed only if range isn't empty
if
(
left
<=
right
)
{
// Change range from absolute to relative and iterate
left
-=
sc
.
get_position
();
right
-=
sc
.
get_position
();
if
(
iterate
(
left
,
right
,
*
iter_var
,
context
))
{
return
Predicate
::
True
(
context
);
}
}
}
}
}
}
}
...
...
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