Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug in the `LimitCache`.

Fixed a bug in the `LimitCache` where the result of the lazy evaluation was not assigned to the result tuple.  This was resulting in a `NullReferenceException` on every `eval`.
  • Loading branch information...
commit 6bd6f5a61cc4ff7af643920c85033400e87eb740 1 parent 9ee0cb7
@otac0n otac0n authored
View
12 Src/IronJS.Runtime/Caches.cs
@@ -10,21 +10,21 @@ public class LimitCache<K, V>
where V : class
{
int size;
- List<Tuple<K, V>> storage =
- new List<Tuple<K, V>>();
+ List<Tuple<K, V>> storage = new List<Tuple<K, V>>();
public LimitCache(int halfSize)
{
this.size = halfSize * 2;
}
- public V Lookup(K key, Lazy<V> value)
+ public V Lookup(K key, Func<V> value)
{
var result = storage.FirstOrDefault(x => x.Item1.Equals(key));
if (result == null)
{
- storage.Add(Tuple.Create(key, value.Value));
+ result = Tuple.Create(key, value());
+ storage.Add(result);
if (storage.Count > size)
{
@@ -42,13 +42,13 @@ public class SplayCache<K, V>
SplayTree<K, V> storage =
new SplayTree<K, V>();
- public V Lookup(K key, Lazy<V> value)
+ public V Lookup(K key, Func<V> value)
{
V cached;
if (!storage.TryGetValue(key, out cached))
{
- storage[key] = cached = value.Value;
+ storage[key] = cached = value();
if (storage.Count > 1024)
{
View
2  Src/IronJS/Native.Global.fs
@@ -22,7 +22,7 @@ module Global =
Utils.trapSyntaxError env (fun () ->
let source = target.Target.Clr.ToString()
env.EvalCache.Lookup(source,
- (lazy
+ (fun (unit) ->
let ast =
target.Function.Env
|> Parser.parse source
View
2  Src/IronJS/Native.Utils.fs
@@ -83,7 +83,7 @@ module Utils =
///
let internal trapSyntaxError (env:Env) (f:unit -> 'a) =
- try
+ try
f()
with
Please sign in to comment.
Something went wrong with that request. Please try again.