Some fixups and enhancements.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4294 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-07-28 02:48:52 +00:00
parent ad74efc332
commit 7c17069a16
4 changed files with 69 additions and 8 deletions
+17 -1
View File
@@ -4,6 +4,22 @@ import mx.utils.*;
public class StringUtil
{
/**
* Get a reasonable hash code for the specified String.
*/
public static function hashCode (str :String) :int
{
var code :int = 0;
if (str != null) {
// sample at most 8 chars
var lastChar :int = Math.min(8, str.length);
for (var ii :int = 0; ii < lastChar; ii++) {
code = code * 31 + str.charCodeAt(ii);
}
}
return code;
}
public static function isBlank (str :String) :Boolean
{
return (str == null) || (str.search("\\S") == -1);
@@ -15,7 +31,7 @@ public class StringUtil
public static function endsWith (str :String, substr :String) :Boolean
{
var startDex :int = str.length - substr.length;
return (startDex >= 0) && (str.indexOf(substr, startDex) > 0);
return (startDex >= 0) && (str.indexOf(substr, startDex) >= 0);
}
/**