- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 20 Mar 2008 16:51:19 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/values In directory hutz:/tmp/cvs-serv30202 Modified Files: CssIdent.java Log Message: now cache hashcode, to avoid too much unnecessary computing Index: CssIdent.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/values/CssIdent.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- CssIdent.java 14 Sep 2005 15:15:33 -0000 1.5 +++ CssIdent.java 20 Mar 2008 16:51:17 -0000 1.6 @@ -13,60 +13,66 @@ */ public class CssIdent extends CssValue { - /** - * Create a new CssIdent - */ - public CssIdent() { - } + private int hashcode = 0; - /** - * Create a new CssIdent - * - * @param s The identificator - */ - public CssIdent(String s) { - value = s; - } + /** + * Create a new CssIdent + */ + public CssIdent() { + } + + /** + * Create a new CssIdent + * + * @param s The identificator + */ + public CssIdent(String s) { + value = s; + } - /** - * Set the value of this ident. - * - * @param s the string representation of the identificator. - * @param frame For errors and warnings reports. - */ - public void set(String s, ApplContext ac) { - value = s; - } + /** + * Set the value of this ident. + * + * @param s the string representation of the identificator. + * @param frame For errors and warnings reports. + */ + public void set(String s, ApplContext ac) { + value = s; + hashcode = 0; + } - /** - * Returns the internal value. - */ - public Object get() { - return value; - } + /** + * Returns the internal value. + */ + public Object get() { + return value; + } - /** - * Returns a string representation of the object. - */ - public String toString() { - return value; - } + /** + * Returns a string representation of the object. + */ + public String toString() { + return value; + } - /** - * Compares two values for equality. - * - * @param value The other value. - */ - public boolean equals(Object value) { - return (value instanceof CssIdent && value.hashCode() == hashCode()); - } + /** + * Compares two values for equality. + * + * @param value The other value. + */ + public boolean equals(Object value) { + return (value instanceof CssIdent && value.hashCode() == hashCode()); + } - /** - * Returns a hashcode for this ident. - */ - public int hashCode() { - return value.toLowerCase().hashCode(); - } + /** + * Returns a hashcode for this ident. + */ + public int hashCode() { + if (hashcode == 0) { + hashcode = value.toLowerCase().hashCode(); + } + return hashcode; + } - private String value; + private String value; }
Received on Thursday, 20 March 2008 16:51:53 UTC