Merge pull request #175 from JinShil/replace_hash_t
Replace `hash_t` and `sizediff_t` with `size_t` and `ptrdiff_t`
This commit is contained in:
commit
ac548c2a24
|
@ -542,7 +542,7 @@ struct GenericPath(F) {
|
||||||
string toString() const nothrow @nogc { return m_path; }
|
string toString() const nothrow @nogc { return m_path; }
|
||||||
|
|
||||||
/// Computes a hash sum, enabling storage within associative arrays.
|
/// Computes a hash sum, enabling storage within associative arrays.
|
||||||
hash_t toHash() const nothrow @trusted
|
size_t toHash() const nothrow @trusted
|
||||||
{
|
{
|
||||||
try return typeid(string).getHash(&m_path);
|
try return typeid(string).getHash(&m_path);
|
||||||
catch (Exception e) assert(false, "getHash for string throws!?");
|
catch (Exception e) assert(false, "getHash for string throws!?");
|
||||||
|
|
|
@ -130,7 +130,7 @@ string stripA(string s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finds the first occurence of any of the characters in `chars`
|
/// Finds the first occurence of any of the characters in `chars`
|
||||||
sizediff_t indexOfAny(string str, string chars)
|
ptrdiff_t indexOfAny(string str, string chars)
|
||||||
@safe pure {
|
@safe pure {
|
||||||
foreach (i, char ch; str)
|
foreach (i, char ch; str)
|
||||||
if (chars.canFind(ch))
|
if (chars.canFind(ch))
|
||||||
|
@ -149,7 +149,7 @@ alias countUntilAny = indexOfAny;
|
||||||
The index of the closing bracket or -1 for unbalanced strings
|
The index of the closing bracket or -1 for unbalanced strings
|
||||||
and strings that don't start with a bracket.
|
and strings that don't start with a bracket.
|
||||||
*/
|
*/
|
||||||
sizediff_t matchBracket(string str, bool nested = true)
|
ptrdiff_t matchBracket(string str, bool nested = true)
|
||||||
@safe pure nothrow {
|
@safe pure nothrow {
|
||||||
if (str.length < 2) return -1;
|
if (str.length < 2) return -1;
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ sizediff_t matchBracket(string str, bool nested = true)
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
static struct Test { string str; sizediff_t res; }
|
static struct Test { string str; ptrdiff_t res; }
|
||||||
enum tests = [
|
enum tests = [
|
||||||
Test("[foo]", 4), Test("<bar>", 4), Test("{baz}", 4),
|
Test("[foo]", 4), Test("<bar>", 4), Test("{baz}", 4),
|
||||||
Test("[", -1), Test("[foo", -1), Test("ab[f]", -1),
|
Test("[", -1), Test("[foo", -1), Test("ab[f]", -1),
|
||||||
|
|
Loading…
Reference in a new issue