<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using Assets.Helpers;
using Assets.Models.Factories;
using UniRx;
using UniRx.Triggers;
using UnityEngine;

namespace Assets.Models
{
    public class CachedDynamicTileManager : DynamicTileManager
    {
        protected string CacheFolderPath;

        public override void Init(List<Factory> factories, World.Settings settings)
        {
            CacheFolderPath = Path.Combine(Application.dataPath, "MapzenGo/CachedTileData/");
            if (!Directory.Exists(CacheFolderPath))
                Directory.CreateDirectory(CacheFolderPath);
            base.Init(factories, settings);
        }

        protected override void LoadTile(Vector2 tileTms, Tile tile)
        {
            var url = string.Format(_mapzenUrl, _mapzenLayers, Zoom, tileTms.x, tileTms.y, _mapzenFormat, _key);

            var tilePath = Path.Combine(CacheFolderPath, Zoom + "_" + tileTms.x + "_" + tileTms.y);
            string mapData;
            if (File.Exists(tilePath))
            {
                var r = new StreamReader(tilePath, Encoding.Default);
                mapData = r.ReadToEnd();
                tile.ConstructTile(mapData);
            }
            else
            {
                ObservableWWW.Get(url).Subscribe(<commit_msg>Move a little local variable to smaller scope<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using Assets.Helpers;
using Assets.Models.Factories;
using UniRx;
using UniRx.Triggers;
using UnityEngine;

namespace Assets.Models
{
    public class CachedDynamicTileManager : DynamicTileManager
    {
        protected string CacheFolderPath;

        public override void Init(List<Factory> factories, World.Settings settings)
        {
            CacheFolderPath = Path.Combine(Application.dataPath, "MapzenGo/CachedTileData/");
            if (!Directory.Exists(CacheFolderPath))
                Directory.CreateDirectory(CacheFolderPath);
            base.Init(factories, settings);
        }

        protected override void LoadTile(Vector2 tileTms, Tile tile)
        {
            var url = string.Format(_mapzenUrl, _mapzenLayers, Zoom, tileTms.x, tileTms.y, _mapzenFormat, _key);
            var tilePath = Path.Combine(CacheFolderPath, Zoom + "_" + tileTms.x + "_" + tileTms.y);
            if (File.Exists(tilePath))
            {
                var r = new StreamReader(tilePath, Encoding.Default);
                var mapData = r.ReadToEnd();
                tile.ConstructTile(mapData);
            }
            else
            {
                ObservableWWW.Get(url).Subscribe(
{'fraction_non_alphanumeric': 0.09040139616055846, 'fraction_numerical': 0.0006980802792321117, 'mean_word_length': 2.520884520884521, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1882141', 'n_tokens_mistral': 804, 'n_tokens_neox': 785, 'n_words': 177}