From owner-svn-src-all@freebsd.org Fri Mar 24 21:32:02 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31B6FD1843F; Fri, 24 Mar 2017 21:32:02 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from smtp-out-so.shaw.ca (smtp-out-so.shaw.ca [64.59.136.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id DC567AFD; Fri, 24 Mar 2017 21:32:01 +0000 (UTC) (envelope-from cy.schubert@komquats.com) Received: from spqr.komquats.com ([96.50.22.10]) by shaw.ca with SMTP id rWoQcWJ7gC3JIrWoRcpLu4; Fri, 24 Mar 2017 15:32:00 -0600 X-Authority-Analysis: v=2.2 cv=XbT59Mx5 c=1 sm=1 tr=0 a=jvE2nwUzI0ECrNeyr98KWA==:117 a=jvE2nwUzI0ECrNeyr98KWA==:17 a=kj9zAlcOel0A:10 a=6Iz7jQTuP9IA:10 a=6I5d2MoRAAAA:8 a=YxBL1-UpAAAA:8 a=oEAUtf0-OmxjpcpeolcA:9 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 0881AFD; Fri, 24 Mar 2017 14:31:57 -0700 (PDT) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id v2OLVvBa047226; Fri, 24 Mar 2017 14:31:57 -0700 (PDT) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201703242131.v2OLVvBa047226@slippy.cwsent.com> X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.6 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Warner Losh cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r315901 - head/sbin/devd In-Reply-To: Message from Warner Losh of "Fri, 24 Mar 2017 13:46:26 -0000." <201703241346.v2ODkQtJ019397@repo.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 24 Mar 2017 14:31:57 -0700 X-CMAE-Envelope: MS4wfMSV6qspgrhzQJE5kGTZ7BqFTupKTj1ucUecTyRw33NJ3Hm79sXi+CCXtFEtQjIu+JWUhl2C9dYJfF29vEE+auLM5xVbkK9aC51pymYmPOoYnO9NnQYw OdUPY7q4RaR3gxlhwOjSBgeliLP4uAKGODSr9CTi6kGC+U66h0SS4XG+ngpazfOnK7l87kcF9JGNw5DWWY0ADVc4EPDQMC5lWGlBUpzfpjF2Mdu/N5pIdjhS E/LOU3zwtbKw9N6iNbHq8yBCa4U9ILeu8j4bNZSlkwM6mjoFTmuomaknSjKSenuf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 21:32:02 -0000 In message <201703241346.v2ODkQtJ019397@repo.freebsd.org>, Warner Losh writes: > Author: imp > Date: Fri Mar 24 13:46:26 2017 > New Revision: 315901 > URL: https://svnweb.freebsd.org/changeset/base/315901 > > Log: > Use a more stream-lined version of fix_value. > > Submitted by: ian@ > > Modified: > head/sbin/devd/devd.cc > head/sbin/devd/devd.hh > > Modified: head/sbin/devd/devd.cc > ============================================================================= > = > --- head/sbin/devd/devd.cc Fri Mar 24 11:46:49 2017 (r315900) > +++ head/sbin/devd/devd.cc Fri Mar 24 13:46:26 2017 (r315901) > @@ -417,24 +417,16 @@ var_list::is_set(const string &var) cons > * converted to ". For all other characters, both \ and following > * character. So the string 'fre\:\"' is translated to 'fred\:"'. > */ > -const std::string & > +std::string > var_list::fix_value(const std::string &val) const > { > - char *tmp, *dst; > - const char *src; > - std::string *rv; > - > - dst = tmp = new char[val.length()]; > - src = val.c_str(); > - while (*src) { > - if (*src == '\\' && src[1] == '"') > - src++; > - else > - *dst++ = *src++; > - } > - rv = new string(tmp); > - delete tmp; > - return *rv; > + std::string rv(val); > + std::string::size_type pos(0); > + > + while ((pos = rv.find("\\\"", pos)) != rv.npos) { > + rv.erase(pos, 1); > + } > + return (rv); > } > > void > > Modified: head/sbin/devd/devd.hh > ============================================================================= > = > --- head/sbin/devd/devd.hh Fri Mar 24 11:46:49 2017 (r315900) > +++ head/sbin/devd/devd.hh Fri Mar 24 13:46:26 2017 (r315901) > @@ -57,7 +57,7 @@ public: > static const std::string nothing; > > private: > - const std::string &fix_value(const std::string &val) const; > + std::string fix_value(const std::string &val) const; > > std::map _vars; > }; > > Thank you Warner. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.