diff --git a/src/main/java/com/threerings/stats/data/Stat.java b/src/main/java/com/threerings/stats/data/Stat.java index 61f97a57..b60ef6f1 100644 --- a/src/main/java/com/threerings/stats/data/Stat.java +++ b/src/main/java/com/threerings/stats/data/Stat.java @@ -87,9 +87,7 @@ public abstract class Stat public static int initType (Type type, Stat prototype) { // compute a code for this stat using the CRC32 hash of its name - _crc.reset(); - _crc.update(type.name().getBytes()); - int code = (int)_crc.getValue(); + int code = crc32(type.name()); // make sure the code does not collide if (_codeToType.containsKey(code)) { @@ -106,6 +104,16 @@ public abstract class Stat return code; } + /** + * Computes and returns the CRC32 hash of the specified string. + */ + public static int crc32 (String string) + { + _crc.reset(); + _crc.update(string.getBytes()); + return (int)_crc.getValue(); + } + /** * Returns the type of this statistic. */