You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Dharamveer Salecha <dh...@wilco-int.com> on 2000/12/02 08:55:26 UTC
PageSequence.java [optimisation]
Hi Fotis,
In the method
org.apache.fop.fo.pagination.PageSequence.formatStaticContent(),
private void formatStaticContent(AreaTree areaTree)
{
...
if (simpleMaster.getRegion(RegionBefore.REGION_CLASS) != null &&
(currentPage.getBefore() != null)) {
..
}
I understand that the currentPage(fo.layout.Page) is generated from
fo.pagination.SimplePageMaster (via using fo.layout.PageMaster which is
built in method end() of SimplePageMaster).
Hence the condition that "currentPage.getBefore() != null" actually depends
on
"simpleMaster.getRegion(RegionBefore.REGION_CLASS) != null"
To sum up:
1. In method SimplePageMaster.end():
The RegionArea for 'before' is added in fo.layout.PageMaster "only when"
simpleMaster.getRegion(RegionBefore.REGION_CLASS) is not null.
2. In method PageMaster.makePage():
The fo.layout.AreaContainer for 'before' is added to fo.layout.Page "only
when"
RegionArea for 'before' is added in fo.layout.PageMaster
Hence, the below indicated conditions seem to be sufficient.
private void formatStaticContent(AreaTree areaTree)
{
...
if (currentPage.getBefore() != null) {
..
}
if (currentPage.getAfter() != null) {
..
}
...
}
Hope I am right.
regards
Dharam
--------------------------------------------------------------------------------
The information transmitted is intended only for the person or entity to which
it is addressed and may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any
action in reliance upon, this information by persons or entities other than the intended recipient is prohibited.
If you received this in error, please contact the sender and delete the materialfrom any computer.
--------------------------------------------------------------------------------
Re: PageSequence.java [optimisation]
Posted by Kelly Campbell <ca...@camk.net>.
Dharamveer,
I think your observation is correct. However, I don't think it is
neccessary to make this change because it's probably good to double check
that the reference which is going to be used is not null.
Also, I'd be very surprised if this bit of code showed up at the top of a
profile as a candidate for optimization since it's just getting a simple
attribute. Even getters which perform a more complex operation underneath
are usually ok to call as many times as you need to if you follow Martin
Fowler's ReplaceTempsWithQuery refactoring (www.refactoring.com)
On the upside, this change might make the code a little simpler and easier
to understand, but as I said, I highly doubt it will make it run any
faster.
-Kelly
On Sat, Dec 02, 2000 at 01:25:26PM +0530, Dharamveer Salecha wrote:
> Hi Fotis,
>
> In the method
> org.apache.fop.fo.pagination.PageSequence.formatStaticContent(),
>
> private void formatStaticContent(AreaTree areaTree)
> {
> ...
> if (simpleMaster.getRegion(RegionBefore.REGION_CLASS) != null &&
> (currentPage.getBefore() != null)) {
> ..
>
> }
>
> I understand that the currentPage(fo.layout.Page) is generated from
> fo.pagination.SimplePageMaster (via using fo.layout.PageMaster which is
> built in method end() of SimplePageMaster).
> Hence the condition that "currentPage.getBefore() != null" actually depends
> on
> "simpleMaster.getRegion(RegionBefore.REGION_CLASS) != null"
>
> To sum up:
> 1. In method SimplePageMaster.end():
> The RegionArea for 'before' is added in fo.layout.PageMaster "only when"
> simpleMaster.getRegion(RegionBefore.REGION_CLASS) is not null.
> 2. In method PageMaster.makePage():
> The fo.layout.AreaContainer for 'before' is added to fo.layout.Page "only
> when"
> RegionArea for 'before' is added in fo.layout.PageMaster
>
> Hence, the below indicated conditions seem to be sufficient.
> private void formatStaticContent(AreaTree areaTree)
> {
> ...
> if (currentPage.getBefore() != null) {
> ..
> }
>
> if (currentPage.getAfter() != null) {
> ..
> }
> ...
> }
>
> Hope I am right.
>
> regards
> Dharam
> --------------------------------------------------------------------------------
> The information transmitted is intended only for the person or entity to which
> it is addressed and may contain confidential and/or privileged material.
> Any review, retransmission, dissemination or other use of, or taking of any
> action in reliance upon, this information by persons or entities other than the intended recipient is prohibited.
> If you received this in error, please contact the sender and delete the materialfrom any computer.
> --------------------------------------------------------------------------------
--
Kelly A. Campbell Software Engineer
camk@channelpoint.com Channelpoint, Inc.
camk@camk.net camk@merlotxml.org Colorado Springs, Co.