Merge lp:~zorba-coders/zorba/bool-opt into lp:zorba

Proposed by Matthias Brantner
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10573
Merged at revision: 10573
Proposed branch: lp:~zorba-coders/zorba/bool-opt
Merge into: lp:zorba
Diff against target: 66 lines (+29/-3)
2 files modified
src/store/naive/simple_item_factory.cpp (+22/-3)
src/store/naive/simple_item_factory.h (+7/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bool-opt
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Matthias Brantner Approve
Review via email: mp+84515@code.launchpad.net

Commit message

optimization: only have exactly two instances of boolean items in the simple store

Description of the change

optimization: only have exactly two instances of boolean items in the simple store

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bool-opt-2011-12-05T18-38-13.116Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 2 Pending.

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bool-opt-2011-12-05T19-42-06.548Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1. Got: 1 Approve, 2 Pending.

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bool-opt-2011-12-05T20-11-08.647Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/store/naive/simple_item_factory.cpp'
2--- src/store/naive/simple_item_factory.cpp 2011-10-15 10:41:19 +0000
3+++ src/store/naive/simple_item_factory.cpp 2011-12-05 18:30:31 +0000
4@@ -43,15 +43,19 @@
5 BasicItemFactory::BasicItemFactory(UriPool* uriPool, QNamePool* qnPool)
6 :
7 theUriPool(uriPool),
8- theQNamePool(qnPool)
9+ theQNamePool(qnPool),
10+ theTrueItem(NULL),
11+ theFalseItem(NULL)
12 {
13 }
14
15
16 BasicItemFactory::~BasicItemFactory()
17 {
18+ theFalseItem = NULL;
19+ theTrueItem = NULL;
20 theQNamePool = NULL;
21- theUriPool = NULL;
22+ theUriPool = NULL;
23 }
24
25
26@@ -421,7 +425,22 @@
27
28 bool BasicItemFactory::createBoolean(store::Item_t& result, xs_boolean value)
29 {
30- result = new BooleanItem(value);
31+ if (value)
32+ {
33+ if (!theTrueItem)
34+ {
35+ theTrueItem = new BooleanItem(true);
36+ }
37+ result = theTrueItem;
38+ }
39+ else
40+ {
41+ if (!theFalseItem)
42+ {
43+ theFalseItem = new BooleanItem(false);
44+ }
45+ result = theFalseItem;
46+ }
47 return true;
48 }
49
50
51=== modified file 'src/store/naive/simple_item_factory.h'
52--- src/store/naive/simple_item_factory.h 2011-10-15 10:41:19 +0000
53+++ src/store/naive/simple_item_factory.h 2011-12-05 18:30:31 +0000
54@@ -50,6 +50,13 @@
55 UriPool * theUriPool;
56 QNamePool * theQNamePool;
57
58+ // boolean items
59+ // we don't need to create more than two, hence
60+ // they are cached here. createBoolean always
61+ // returns one of them
62+ store::Item_t theTrueItem;
63+ store::Item_t theFalseItem;
64+
65 public:
66 BasicItemFactory(UriPool* uriPool, QNamePool* qnPool);
67

Subscribers

People subscribed via source and target branches