Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container registry
Model registry
Monitor
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
f1fa749a
Commit
f1fa749a
authored
8 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
unbounded regexp optimisation improvements
parent
e238c4f8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx
+23
-29
23 additions, 29 deletions
...2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx
with
23 additions
and
29 deletions
alib2algo/src/regexp/simplify/RegExpOptimizeUnboundedPart.cxx
+
23
−
29
View file @
f1fa749a
...
@@ -590,7 +590,7 @@ bool RegExpOptimize::V5( UnboundedRegExpAlternation & node ) {
...
@@ -590,7 +590,7 @@ bool RegExpOptimize::V5( UnboundedRegExpAlternation & node ) {
if
(
iterConcat
->
getChildren
().
size
(
)
!=
(
unsigned
)
distance
(
std
::
next
(
itC
),
concat
->
getChildren
().
end
(
)
)
if
(
iterConcat
->
getChildren
().
size
(
)
!=
(
unsigned
)
distance
(
std
::
next
(
itC
),
concat
->
getChildren
().
end
(
)
)
||
!
equal
(
iterConcat
->
getChildren
().
begin
(
),
iterConcat
->
getChildren
().
end
(
),
std
::
next
(
itC
),
||
!
equal
(
iterConcat
->
getChildren
().
begin
(
),
iterConcat
->
getChildren
().
end
(
),
std
::
next
(
itC
),
[
](
const
std
::
smart_ptr
<
UnboundedRegExpElement
>
&
a
,
const
std
::
smart_ptr
<
UnboundedRegExpElement
>
&
b
)
->
bool
{
return
*
a
==
*
b
;
}
)
)
{
[
](
const
std
::
smart_ptr
<
UnboundedRegExpElement
>
&
a
,
const
std
::
smart_ptr
<
UnboundedRegExpElement
>
&
b
)
->
bool
{
return
*
a
==
*
b
;
}
)
)
{
itC
++
;
++
itC
;
continue
;
continue
;
}
}
advance
(
itStartY
,
(
int
)
iterConcat
->
getChildren
().
size
(
)
);
advance
(
itStartY
,
(
int
)
iterConcat
->
getChildren
().
size
(
)
);
...
@@ -769,7 +769,7 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation & node ) {
...
@@ -769,7 +769,7 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation & node ) {
UnboundedRegExpIteration
*
iter
=
dynamic_cast
<
UnboundedRegExpIteration
*>
(
it
->
get
()
);
UnboundedRegExpIteration
*
iter
=
dynamic_cast
<
UnboundedRegExpIteration
*>
(
it
->
get
()
);
if
(
!
iter
)
{
if
(
!
iter
)
{
it
++
;
++
it
;
continue
;
continue
;
}
}
...
@@ -818,64 +818,58 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation & node ) {
...
@@ -818,64 +818,58 @@ bool RegExpOptimize::V8( UnboundedRegExpConcatenation & node ) {
*
@
param
node
UnboundedRegExpConcatenation
node
*
@
param
node
UnboundedRegExpConcatenation
node
*
@
return
bool
true
if
optimization
applied
else
false
*
@
return
bool
true
if
optimization
applied
else
false
*/
*/
bool
RegExpOptimize
::
V9
(
UnboundedRegExpConcatenation
&
/*
node
*/
)
{
bool
RegExpOptimize
::
V9
(
UnboundedRegExpConcatenation
&
node
)
{
/*
bool optimized = false;
*/
bool
optimized
=
false
;
// interpretation: if concat (C1) with iter && iteration's element is concat (C2), then:
// interpretation: if concat (C1) with iter && iteration's element is concat (C2), then:
// simultaneously iterate through C1 and C2. (axy)*axz=ax(yax)*z -> get ax that is same and relocate them...
// simultaneously iterate through C1 and C2. (axy)*axz=ax(yax)*z -> get ax that is same and relocate them...
/*
for
(
auto
it
=
node
->
elements
.
begin
(
)
;
it
!=
node
->
elements
.
end
(
)
;
)
for
(
auto
it
=
node
.
getChildren
().
begin
(
)
;
it
!=
node
.
getChildren
().
end
(
)
;
)
{
{
UnboundedRegExpIteration
*
iter
=
dynamic_cast
<
UnboundedRegExpIteration
*>
(
it
->
get
()
);
UnboundedRegExpIteration
*
iter
=
dynamic_cast
<
UnboundedRegExpIteration
*>
(
it
->
get
()
);
if
(
!
iter
)
if
(
!
iter
)
{
{
++
it
;
it
++
;
continue
;
continue
;
}
}
UnboundedRegExpConcatenation
*
concat
=
dynamic_cast
<
UnboundedRegExpConcatenation
*>
(
iter
->
element
.
get
()
);
UnboundedRegExpConcatenation
*
concat
=
dynamic_cast
<
UnboundedRegExpConcatenation
*>
(
iter
->
getChild
().
get
()
);
if
(
!
concat
)
if
(
!
concat
)
{
{
++
it
;
it
++
;
continue
;
continue
;
}
}
// find range from <it+1;sth> and <concat.begin;sth> that is equal
// find range from <it+1;sth> and <concat.begin;sth> that is equal
auto
c1Iter
=
std
::
next
(
it
),
c2Iter
=
concat
->
elements
.
begin
(
);
auto
c1Iter
=
std
::
next
(
it
),
c2Iter
=
concat
->
getChildren
().
begin
(
);
while
(
c1Iter
!=
node
->
elements
.
end
()
&&
c2Iter
!=
concat
->
elements
.
end
(
)
&&
**
c1Iter
==
**
c2Iter
)
while
(
c1Iter
!=
node
.
getChildren
().
end
()
&&
c2Iter
!=
concat
->
getChildren
().
end
(
)
&&
**
c1Iter
==
**
c2Iter
)
{
{
++
c1Iter
;
c1Iter
++
;
++
c2Iter
;
c2Iter
++
;
}
}
if
(
c1Iter
==
std
::
next
(
it
)
)
if
(
c1Iter
==
std
::
next
(
it
)
)
{
{
++
it
;
it
++
;
continue
;
continue
;
}
}
// std::cout << "xy" << std::endl;
// std::cout << "xy" << std::endl;
// UnboundedRegExpConcatenation* tmp = new UnboundedRegExpConcatenation( );
// UnboundedRegExpConcatenation* tmp = new UnboundedRegExpConcatenation( );
// tmp->
elements.
insert( tmp->
elements
.end( ), std::next( it ), c1Iter );
// tmp->insert( tmp->
getChildren()
.end( ), std::next( it ), c1Iter );
// std::cout << RegExp( tmp ) << std::endl;
// std::cout << RegExp( tmp ) << std::endl;
// copy the range <it;sth>, delete it and go back to the iter node
// copy the range <it;sth>, delete it and go back to the iter node
std
::
vector
<
std
::
smart_ptr
<
UnboundedRegExpElement
>
>
copyRange
;
std
::
vector
<
std
::
smart_ptr
<
UnboundedRegExpElement
>
>
copyRange
;
copyRange
.
insert
(
copyRange
.
end
(),
std
::
next
(
it
),
c1Iter
);
copyRange
.
insert
(
copyRange
.
end
(),
std
::
next
(
it
),
c1Iter
);
it
=
node
->
elements
.
erase
(
std
::
next
(
it
),
c1Iter
);
it
=
node
.
getChildren
()
.
erase
(
std
::
next
(
it
),
c1Iter
);
it
=
std
::
prev
(
it
);
it
=
std
::
prev
(
it
);
// insert that range before it position
// insert that range before it position
node
->
elements
.
insert
(
it
,
copyRange
.
begin
(
),
copyRange
.
end
(
)
);
node
.
insert
(
it
,
copyRange
.
begin
(
),
copyRange
.
end
(
)
);
// alter the iteration's concat node
// alter the iteration's concat node
copyRange
.
clear
(
);
copyRange
.
clear
(
);
copyRange
.
insert
(
copyRange
.
end
(),
concat
->
elements
.
begin
(
),
c2Iter
);
copyRange
.
insert
(
copyRange
.
end
(),
concat
->
getChildren
()
.
begin
(
),
c2Iter
);
concat
->
elements
.
erase
(
concat
->
elements
.
begin
(
),
c2Iter
);
concat
->
getChildren
()
.
erase
(
concat
->
getChildren
()
.
begin
(
),
c2Iter
);
concat
->
elements
.
insert
(
concat
->
elements
.
end
(),
copyRange
.
begin
(
),
copyRange
.
end
(
)
);
concat
->
insert
(
concat
->
getChildren
()
.
end
(),
copyRange
.
begin
(
),
copyRange
.
end
(
)
);
}
}
return
optimized
;
*/
return
optimized
;
return
false
;
// FIXME
}
}
/**
/**
...
...
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