Return-Path: X-Original-To: apmail-zest-dev-archive@minotaur.apache.org Delivered-To: apmail-zest-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3898B17455 for ; Sat, 23 May 2015 03:27:39 +0000 (UTC) Received: (qmail 13388 invoked by uid 500); 23 May 2015 03:27:39 -0000 Delivered-To: apmail-zest-dev-archive@zest.apache.org Received: (qmail 13355 invoked by uid 500); 23 May 2015 03:27:39 -0000 Mailing-List: contact dev-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list dev@zest.apache.org Received: (qmail 13341 invoked by uid 99); 23 May 2015 03:27:38 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 May 2015 03:27:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 49B02C0044 for ; Sat, 23 May 2015 03:27:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.981 X-Spam-Level: ** X-Spam-Status: No, score=2.981 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id c6oIt1ClAPaH for ; Sat, 23 May 2015 03:27:31 +0000 (UTC) Received: from mail-ig0-f180.google.com (mail-ig0-f180.google.com [209.85.213.180]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 6DD1520343 for ; Sat, 23 May 2015 03:27:30 +0000 (UTC) Received: by igbhj9 with SMTP id hj9so5168967igb.1 for ; Fri, 22 May 2015 20:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=7hyVMiJwgu7Jtb1PRf/BPOkinY36QkVFt1lrjnXqbco=; b=aLjID7N+4OKGVu46/vgueiM7NF4LPNjJtPrnA/g3xz6IXKiFNAKiC1oj1OYffN8Qmz cHFJ1UGwE6Gqd48f8b//ZSBofZ0be1Egk1R98C0I0JHuR0W9f51ZmStvhocwBNiy/f4Q 9h4HvxkLQMtnDf0MyT2eIOYFakn6RCal7y4sorlwVXEZfqt5dEl3SeOQkB3r1MG1Agvp x0LgV/X/ezMen8JbV1bRtAon1i/VsEPppX7yZXz0xq1Vun5+uWJDsJYuJ6ZmEE55Wuvv hSAHto6V1C1DyfdK0KreguHruHOXmfSp2RyMqf7J66N42EkoZtrffpd7M4cghC9Gs+Iv gWcQ== X-Received: by 10.43.151.83 with SMTP id kr19mr12731251icc.3.1432351604229; Fri, 22 May 2015 20:26:44 -0700 (PDT) MIME-Version: 1.0 Sender: hedhman@gmail.com Received: by 10.36.98.18 with HTTP; Fri, 22 May 2015 20:26:23 -0700 (PDT) In-Reply-To: <555EF17F.7030707@nosphere.org> References: <555EF17F.7030707@nosphere.org> From: Niclas Hedhman Date: Sat, 23 May 2015 11:26:23 +0800 X-Google-Sender-Auth: UNoiKIyxpSdcJXuoxsd8pK2aJxU Message-ID: Subject: Re: Prototype cloning? To: dev Content-Type: multipart/alternative; boundary=001a11c2fd9e904f400516b75870 --001a11c2fd9e904f400516b75870 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, May 22, 2015 at 5:06 PM, Paul Merlin wrote: > Niclas Hedhman a =C3=A9crit : > > There is this sub-optimal section in the ValueBuilderWithPrototype.java > > > > // @TODO there is probably a more efficient way to do this > > ValueSerialization valueSerialization =3D > currentModule.valueSerialization(); > > String serialized =3D valueSerialization.serialize( prototype ); > > value =3D valueSerialization.deserialize( valueModel.valueType(), > serialized); > > > > And this approach is of course a performance hog, as well as introducin= g > a > > strange problem about initializing ValueComposites with Associations. > > > > And it should be required to clone via serialization, but I understand > that > > the effort might be substantial... Any takers?? > Couldn't it be replaced by programmatic cloning of underlying > AssociationStateHolder? Not trivial though. > Yes, I think that is how it should be done, and yes, I agree it isn't trivial, since the Prototype object is Mutable, although the resulting ValueInstance isn't. A different approach could be "late cloning". I am not sure that my apps are typical or not, but I very seldom use the prototyping feature, and almost always "1 ValueBuilder per instantiated Value". And if that is the most common case, yet we don't want to give up the "prototype instance stamping" feature, I think it is possible to clone from the "last created object into the 'new' prototype" when user try to set some prototype property after newInstance(). That might actually be easier to implement. AND, then we can look at whether "prototype instance stamping" is faster than creation of a new ValueBuilder. IF NOT, then it would make sense to do the Prototype feature at a higher level, perhaps in 3.0, possibly by leveraging Concerns and have it is a library instead. * I imagine that Concerns could cache the property set() calls, and on newInstance() populate the ValueBuilder from scratch. No time to flesh out the details here. Cheers --=20 Niclas Hedhman, Software Developer http://zest.apache.org - New Energy for Java --001a11c2fd9e904f400516b75870--