Skip to content

Commit

Permalink
some more enums as const
Browse files Browse the repository at this point in the history
  • Loading branch information
Egbert.Voigt authored and Egbert.Voigt committed May 5, 2020
1 parent 3283a79 commit fd7cc1a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
Binary file modified model/DRuntimeMisc.zargo
Binary file not shown.
15 changes: 7 additions & 8 deletions source/antlr/v4/runtime/misc/Array2DHashSet.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2018 The ANTLR Project. All rights reserved.
* Copyright (c) 2012-2020 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
Expand All @@ -22,11 +22,11 @@ import antlr.v4.runtime.misc;
class Array2DHashSet(T)
{

public static immutable int INITAL_CAPACITY = 16;
enum int INITAL_CAPACITY = 16;

public static immutable int INITAL_BUCKET_CAPACITY = 8;
enum int INITAL_BUCKET_CAPACITY = 8;

public static immutable double LOAD_FACTOR = 0.75;
enum double LOAD_FACTOR = 0.75;

protected size_t function(Object o) @trusted nothrow hashOfFp;

Expand Down Expand Up @@ -65,9 +65,8 @@ class Array2DHashSet(T)
this(hashOfFp, opEqualsFp, INITAL_CAPACITY, INITAL_BUCKET_CAPACITY);
}

public this(size_t function(Object o) @trusted nothrow hashOfFp,
bool function(Object a, Object b) opEqualsFp,
int initialCapacity, int initialBucketCapacity)
public this(size_t function(Object o) @trusted nothrow hashOfFp, bool function(Object a,
Object b) opEqualsFp, int initialCapacity, int initialBucketCapacity)
{
if (hashOfFp is null || opEqualsFp is null)
{
Expand Down Expand Up @@ -198,7 +197,7 @@ class Array2DHashSet(T)
{
if (o is this)
return true;
if (! cast(Array2DHashSet) o)
if (!cast(Array2DHashSet) o)
return false;
Array2DHashSet!T other = cast(Array2DHashSet!T) o;
if (other.size() != size())
Expand Down
15 changes: 8 additions & 7 deletions source/antlr/v4/runtime/misc/BitSet.d
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ struct BitSet

public int nextSetBit(int fromIndex)
{
foreach (i, el; bitSet) {
foreach (i, el; bitSet)
{
if (i > fromIndex && el == true)
return to!int(i);
}
Expand Down Expand Up @@ -94,7 +95,7 @@ struct BitSet
res ~= to!string(j) ~ ", ";
}
}
return format!"{%s}"(res[0 .. $-2]);
return format!"{%s}"(res[0 .. $ - 2]);
}
else
return "{}";
Expand Down Expand Up @@ -134,9 +135,8 @@ struct BitSet
auto maxLenght = max(this.bitSet.length, bits.bitSet.length);
if (this.bitSet.length < maxLenght)
this.bitSet.length = maxLenght;
else
if (bits.values.length < maxLenght)
bits.values.length = maxLenght;
else if (bits.values.length < maxLenght)
bits.values.length = maxLenght;
result.bitSet = this.bitSet | bits.bitSet;
return result;
}
Expand All @@ -145,11 +145,12 @@ struct BitSet
{
import std.conv;
import std.array : join;

string[] res;
int index;
foreach(i, el; bitSet)
foreach (i, el; bitSet)
{
if(el)
if (el)
res ~= to!string(i);
}
return "{" ~ join(res, ",") ~ "}";
Expand Down
3 changes: 2 additions & 1 deletion source/antlr/v4/runtime/misc/IntegerList.d
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class IntegerList
public final void removeRange(int fromIndex, int toIndex)
in
{
assert(fromIndex >= 0 || toIndex >= 0 || fromIndex <= data_.length || toIndex <= data_.length, "IndexOutOfBoundsException");
assert(fromIndex >= 0 || toIndex >= 0 || fromIndex <= data_.length
|| toIndex <= data_.length, "IndexOutOfBoundsException");
assert(fromIndex <= toIndex, "IllegalArgumentException");
}
do
Expand Down
6 changes: 3 additions & 3 deletions source/antlr/v4/runtime/misc/Interval.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Interval

public static const Interval INVALID = new Interval(-1, -2);

private static Interval[] cache = new Interval[INTERVAL_POOL_MAX_VALUE+1];
private static Interval[] cache = new Interval[INTERVAL_POOL_MAX_VALUE + 1];

public int a;

Expand Down Expand Up @@ -192,8 +192,8 @@ class Interval

unittest
{
auto a = new Interval(1 , 2);
auto b = new Interval(3 , 10);
auto a = new Interval(1, 2);
auto b = new Interval(3, 10);
assert(b.adjacent(a));
assert(!b.adjacent(new Interval(1, 6)));
assert(!b.adjacent(new Interval(10, 16)));
Expand Down
2 changes: 1 addition & 1 deletion source/antlr/v4/runtime/misc/IntervalSet.d
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class IntervalSet : IntSet
addAll(set);
}

public this(int[] els ...)
public this(int[] els...)
{
foreach (int e; els)
add(e);
Expand Down
4 changes: 2 additions & 2 deletions source/antlr/v4/runtime/misc/MurmurHash.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2018 The ANTLR Project. All rights reserved.
* Copyright (c) 2012-2020 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
Expand All @@ -16,7 +16,7 @@ import std.stdio;
class MurmurHash
{

public static immutable size_t DEFAULT_SEED = 0;
enum size_t DEFAULT_SEED = 0;

/**
* Initialize the hash using the default seed value.
Expand Down

0 comments on commit fd7cc1a

Please sign in to comment.