From 574ccee478b9da9457cdf0e476b8df6eb584b580 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 16 Jul 2012 06:48:11 +0000 Subject: Minor memory management, performance, and tracing improvements. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1361917 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp') diff --git a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp index 4b5dc8db6b..2771d7cd9c 100644 --- a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp +++ b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp @@ -38,7 +38,7 @@ const string cartId("1234"); * Get the shopping cart from the cache. Return an empty * cart if not found. */ -const list getcart(const value& id, const lambda&)> cache) { +const list getcart(const value& id, const lambda&)>& cache) { const value cart = cache(mklist("get", mklist(id))); cerr << "cart value: " << cart << "\n"; const failable fcart = cart; @@ -53,7 +53,7 @@ const list getcart(const value& id, const lambda& /** * Post a new item to the cart. Create a new cart if necessary. */ -const failable post(unused const list& collection, const value& item, const lambda&)> cache) { +const failable post(unused const list& collection, const value& item, const lambda&)>& cache) { const value id(mkuuid()); const list newItem(mklist("entry", cadr(car(item)), mklist("id", id), cadddr(car(item)))); const list cart(cons(newItem, getcart(cartId, cache))); @@ -75,7 +75,7 @@ const value find(const value& id, const list& cart) { /** * Return items from the cart. */ -const failable get(const list& id, const lambda&)> cache) { +const failable get(const list& id, const lambda&)>& cache) { if (isNil(id)) return value(mklist(append(mklist("feed", mklist("title", string("Your Cart")), mklist("id", cartId)), getcart(cartId, cache)))); return find(car(id), getcart(cartId, cache)); @@ -84,7 +84,7 @@ const failable get(const list& id, const lambda del(const list& id, unused const lambda&)> cache) { +const failable del(const list& id, unused const lambda&)>& cache) { if (isNil(id)) return cache(mklist("delete", mklist(cartId))); return value(true); @@ -109,7 +109,7 @@ const double sum(const list& items) { /** * Return the total price of the items in the cart. */ -const failable total(const lambda&)> cache) { +const failable total(const lambda&)>& cache) { const list cart(getcart(cartId, cache)); return value(sum(cart)); } -- cgit v1.2.3