1、normal：直接入栈
2、single task：只维持一个实例，该实例之上的全部出栈
3、single top：栈顶只维持一个实例
4、single task with params
5、single top with params
352058
function (path, params) {
  let existInHistory = -1
  if (this.launcherMode != 'normal' && this.history.length > 0) {
    for (let i=this.history.length-1; i>=0; i--) {
      if (path == this.history[i][1] && (!this.compareParam || (this.compareParam && (!params && !this.history[i][2] || equal(params, this.history[i][2]))))) {
        existInHistory = i
        break
      }
      if (this.launcherMode === 'singleTop') {
        break
      }
    }
  }
  if (existInHistory < 0) {
    this.rid++
    let historyId = this.rid + '_' + (+new Date)
    this.history.push([historyId, path, params && Object.keys(params).length > 0 ? params : null])
  } else {
    this.finishedHistoryIds.push('_')
    this.history = this.history.slice(0, existInHistory + 1)
    let currentEndRoute = this.currentRoute.slice(-1)[0]
    this.history.slice(-1)[0].push({reuse: currentEndRoute && currentEndRoute[1].meta && currentEndRoute[1].meta.reuse})
  }
  if (this.history.length > this.maxHistorySize) {
    this.finishedHistoryIds.push('_')
    this.history = this.history.slice(0-this.maxHistorySize)
  }
}
1237142
function otfContours2ttfContours(otfContours) {
            if (!otfContours || !otfContours.length) {
                return otfContours;
            }
            var contours = [];
            for (var i = 0, l = otfContours.length; i < l; i++) {

                // 这里可能由于转换错误导致空轮廓，需要去除
                if (otfContours[i][0]) {
                    contours.push(transformContour(otfContours[i]));
                }
            }

            return contours;
        }
988634
public void rmLittlePathByScore() {
        int maxTo = -1;
        Term temp = null;
        for (int i = 0; i < terms.length; i++) {
            if (terms[i] == null) {
                continue;
            }
            Term maxTerm = null;
            double maxScore = 0;
            Term term = terms[i];
            // 找到自身分数对大最长的

            do {
                if (maxTerm == null || maxScore > term.score()) {
                    maxTerm = term;
                } else if (maxScore == term.score() && maxTerm.getName().length() < term.getName().length()) {
                    maxTerm = term;
                }

            } while ((term = term.next()) != null);
            term = maxTerm;
            do {
                maxTo = term.toValue();
                maxScore = term.score();
                if (maxTo - i == 1 || i + 1 == terms.length)
                    continue;
                boolean flag = true;// 可以删除
                out: for (int j = i; j < maxTo; j++) {
                    temp = terms[j];
                    if (temp == null) {
                        continue;
                    }
                    do {
                        if (temp.toValue() > maxTo || temp.score() < maxScore) {
                            flag = false;
                            break out;
                        }
                    } while ((temp = temp.next()) != null);
                }
                // 验证通过可以删除了
                if (flag) {
                    for (int j = i + 1; j < maxTo; j++) {
                        terms[j] = null;
                    }
                }
            } while ((term = term.next()) != null);
        }
    }
1181655
function handleParamBelong (field, names, space, factory) {

            var curr = names.shift();
            if ( curr ) {
                // 如果参数下级为空，创建一个新的，用于给下面插入
                if ( space.length === 0 ) {
                    space[0] = {
                        field : curr
                    }
                }
                space.forEach(function (item) {
                    // grunt.log.writeflags(item)
                    if ( item && item.field === curr ) {

                        if ( !item[field] ) {
                            item[field] = [];
                        }
                        if ( names.length === 1 ) {
                            // fix `field` for `param`
                            factory.field = names.shift();

                            item[field].push(factory)
                        } else {
                            handleParamBelong(field, names, item[field], factory);
                        }
                    }
                });
            }
        }
504873
function Context(ret) {
    this.ret = ret;

    // 初始化文件列表
    var fileMap = this.filePathMap = ret.src;

    // 初始化资源映射表
    var fileIdMap = this.fileIdMap = {};
    var fileUrlMap = this.fileUrlMap = {};
    var files = this.files = [];
    Object.keys(fileMap).forEach(function (subpath) {
        var file = fileMap[subpath];
        files.push(file);
        fileIdMap[file.id] = file;
        if (file.release) {
            fileUrlMap[file.getUrl()] = file;
        }
    });
    this.resIdMap = {};
    this.root = fis.project.getProjectPath();
    this.requireConfig = getAmdConfig();
    this.moduleConfig = amdHelper.initModuleConfig(this.requireConfig, this.root);
    this.toPackItems = [];
}
65153
function getApiResult(data, status, message) {
    var result = {};

    // 成功处理并返回
    if (!status) {
        result.data = data;
    } else {
        result.status = status;
        result.statusInfo = {
            message: message
        };
    }

    return result;
}
422196
private int ssMedian5(int Td, int PA, int v1, int v2, int v3, int v4, int v5) {
        int t;
        if (T[start + Td + SA[PA + SA[v2]]] > T[start + Td + SA[PA + SA[v3]]]) {
            t = v2;
            v2 = v3;
            v3 = t;

        }
        if (T[start + Td + SA[PA + SA[v4]]] > T[start + Td + SA[PA + SA[v5]]]) {
            t = v4;
            v4 = v5;
            v5 = t;
        }
        if (T[start + Td + SA[PA + SA[v2]]] > T[start + Td + SA[PA + SA[v4]]]) {
            t = v2;
            v2 = v4;
            v4 = t;
            t = v3;
            v3 = v5;
            v5 = t;
        }
        if (T[start + Td + SA[PA + SA[v1]]] > T[start + Td + SA[PA + SA[v3]]]) {
            t = v1;
            v1 = v3;
            v3 = t;
        }
        if (T[start + Td + SA[PA + SA[v1]]] > T[start + Td + SA[PA + SA[v4]]]) {
            t = v1;
            v1 = v4;
            v4 = t;
            t = v3;
            v3 = v5;
            v5 = t;
        }
        if (T[start + Td + SA[PA + SA[v3]]] > T[start + Td + SA[PA + SA[v4]]]) {
            return v4;
        }
        return v3;
    }
183473
def get_task_list(userid = nil, since = nil, delegated = nil, task_types = nil, task_statuses = nil)
      magic_parameters = {
        action: 'GetTaskList',
        userid: userid,
        parameter1: since,
        parameter2: task_types,
        parameter3: task_statuses,
        parameter4: delegated
      }
      response = magic(magic_parameters)

      unless response.is_a?(Array)
        response = [ response ]
      end

      response
    end
995739
async function EvaluationMultipleSeq(client) {

    console.log("----------流式评估示例------------")
    let startTime = Date.now()
    try {
        let sessionId = uuid.v1();
        // 初始化评估
        let initReq = new models.InitOralProcessRequest();
        initReq.SessionId = sessionId;
        initReq.RefText = "Rex was a big dog.";
        // 设置为流式评估
        initReq.WorkMode = 0;
        initReq.EvalMode = 1;
        initReq.ScoreCoeff = 3.5;
        let initRsp = await InitOralProcess(client, initReq);
        console.log("初始化返回结果：")
        console.log(initRsp.to_json_string())

        let data = fs.readFileSync(AUDIO_FOR_SEQ)

        let PKG_SIZE = 16 * 1024;
        let pkgNum = Math.ceil(data.length / PKG_SIZE);
        for (let i = 1; i <= pkgNum; i++) {
            let lastIndex = i * PKG_SIZE;
            if (i == pkgNum) {
                lastIndex = data.length;
            }
            let buf = data.slice((i - 1) * PKG_SIZE, lastIndex)
            let base64Str = buf.toString("base64")
            // 传输评估音频数据
            let transReq = new models.TransmitOralProcessRequest();
            transReq.SessionId = sessionId;
            transReq.VoiceFileType = 2;
            transReq.VoiceEncodeType = 1;
            transReq.SeqId = i;
            if (i == pkgNum) {
                transReq.IsEnd = 1;
            } else {
                transReq.IsEnd = 0;
            }
            transReq.UserVoiceData = base64Str;
            let transRsp = await TransmitOralProcess(client, transReq)
            console.log("评估结果：")
            console.log(transRsp.to_json_string())
            let costTime = Date.now() - startTime
            console.log("完成评估耗时:" + costTime)

        }

        console.log("-----------当评估超时，或者其它业务原因，可以重发一次 IsEnd = 1 的传输查询评估结果------------")
        let transReq = new models.TransmitOralProcessRequest();
        transReq.SessionId = sessionId;
        transReq.VoiceFileType = 2;
        transReq.VoiceEncodeType = 1;
        transReq.SeqId = 1;
        //查询结果设置 IsQuery 为1
        transReq.IsQuery = 1;
        transReq.IsEnd = 0;
        transReq.UserVoiceData = "";
        let transRsp = await TransmitOralProcess(client, transReq)
        console.log("查询结果：")
        console.log(transRsp.to_json_string())

    } catch (err) {
        console.log("评估失败", err)
    } finally {
        console.log("-----------完成流式评估------------\n\n")
    }
}
1269790
function (param, repeatTime, traversePath) {
      var result = null;
      if (param.defaultValue) {
        // 数组有默认值时, 求默认值
        result = '数组的默认值不能解析为数组: ' + param.defaultValue;
        try {
          var dv = eval(param.defaultValue);
          if (Array.isArray(dv)) {
            result = dv;
          }
        } catch (e) {
          // console.warn('数组的默认值不能解析为数组: ' + e);
        }
      } else if (param.genExpression) {
        result = this._evalExp(param.genExpression, {
          _isArray: 1,
          type: param.type,
          isArray: param.isArray
        }, this.ds);
        if (!Array.isArray(result)) {
          result = '生成规则的返回值不是数组: ' + JSON.stringify(result);
        }
      } else {
        // 默认生成三组数据
        repeatTime = isNaN(repeatTime) ? 3 : repeatTime <= 0 ? 3 : repeatTime;
        var genArr = function () {
          var arr = [];
          var pathNodeNum = null;
          for (var i = 0; i < repeatTime; i++) {
            pathNodeNum = traversePath.length;
            arr.push(this._getMockOfDatatypeId(param.type, param.name, traversePath));
            traversePath.length = pathNodeNum;
          }
          return arr;
        };
        if (param.isArray) {
          result = [];
          for (var i = 0; i < repeatTime; i++) {
            result.push(genArr.call(this));
          }
        } else {
          result = genArr.call(this);
        }
      }
      return result;
    }
258574
public function beforeSwooleStart()
    {
        parent::beforeSwooleStart();
        //创建task用的taskid
        $this->task_atomic = new \swoole_atomic(0);
        //创建task用的id->pid共享内存表不至于同时超过1024个任务吧
        $this->tid_pid_table = new \swoole_table(1024);
        $this->tid_pid_table->column('pid', \swoole_table::TYPE_INT, 8);
        $this->tid_pid_table->column('des', \swoole_table::TYPE_STRING, 100);
        $this->tid_pid_table->column('start_time', \swoole_table::TYPE_INT, 8);
        $this->tid_pid_table->create();
        //创建task用的锁
        $this->task_lock = new \swoole_lock(SWOOLE_MUTEX);
        //开启用户进程
        $this->startProcess();
        //开启一个UDP用于发graylog
        GrayLogHelp::init();
        //开启Cluster端口
        ClusterHelp::getInstance()->buildPort();
        //Timer
        Timer::init();
        //init锁
        $this->initLock = new \swoole_lock(SWOOLE_RWLOCK);
        //reload锁
        for ($i = 0; $i < $this->worker_num; ++$i) {
            $lock = new \swoole_lock(SWOOLE_MUTEX);
            $this->reloadLockMap[$i] = $lock;
        }
    }
361531
function () {
            if (opt.globalTask.state === 'cancel') return;
            for (; that._uploadingThreadCount < that.uploadMaxThread && task.currentIndex < task.chunkCount; task.currentIndex++) {
                var chunk = task.chunks[task.currentIndex];
                if (chunk.state !== 'waiting') continue;
                (function (chunk) {
                    chunk.state = 'uploading';
                    task.uploadingCount++;
                    that._uploadingThreadCount++;
                    uploadSingleChunk.call(that, task, chunk, function (error, data) {
                        task.uploadingCount--;
                        that._uploadingThreadCount--;
                        if (error) { // 错误马上结束
                            chunk.state = 'error';
                            uploadError(error, data);
                        } else {
                            chunk.state = 'success';
                            if (task.uploadingCount <= 0 && task.currentIndex >= task.chunkCount) { // 全部完成
                                uploadSuccess();
                            } else { // 未完成，处理执行下一个分片
                                uploadNextChunk();
                            }
                        }
                    });
                })(chunk);
            }
            if (task.uploadingCount === 0 && task.currentIndex === task.chunks.length) { // 全部不需要上传
                uploadSuccess();
            }
        }
532760
function(tasks, callback) {

      var keys; var length; var i; var results; var kind;
      var updated_tasks = [];
      var is_object;
      var counter = 0;

      if (isArray(tasks)) {

        length = tasks.length;
        results = [];

      } else if (isObject(tasks)) {

        is_object = true;
        keys = ObjectKeys(tasks);
        length = keys.length;
        results = {};

      } else {
        return callback();
      }

      for (i=0; i<length; i++) {

        if (is_object) {
          updated_tasks.push({ k: keys[i], t: tasks[keys[i]] });
        } else {
          updated_tasks.push({ k: i, t: tasks[i] });
        }

      }

      updated_tasks.forEach(function(task_object) {

        task_object.t(function(err, result) {
          if (err) return callback(err);

          results[task_object.k] = result;

          counter++;
          if (counter == length) callback(null, results);
        });

      });

    }
252026
function(url, params, onsuccess, onfail) {
    // url中包含 get 参数和 params 合并
    if (_typeof(params) == 'object') params = _params_2_url(params);
    else params = '';

    if (params) url = url + '?' + params;
    return request('GET', url, '', onsuccess, onfail);
  }
1145205
function ttf2svg(ttfBuffer, options) {

    options = options || {};

    // 读取ttf二进制流
    if (ttfBuffer instanceof ArrayBuffer) {
        var reader = new TTFReader();
        var ttfObject = reader.read(ttfBuffer);
        reader.dispose();

        return ttfobject2svg(ttfObject, options);
    }
    // 读取ttfObject
    else if (ttfBuffer.version && ttfBuffer.glyf) {

        return ttfobject2svg(ttfBuffer, options);
    }

    error.raise(10109);
}
80011
function local(backendTplServer) {
    backendTplServer.app.get('/news/local', function(request, response) {
        // 公共的数据模型可以抽取到出来, 作为一个文件 require 进来, 防止多处重复定义数据模型的规则
        var data = Mock.mock({
            'news|10-20': [news]
        });

        // 单独修改其中的某个数据
        data.news[0].getUrls = function() {
            return [
                'http://dummyimage.com/112x74,',
                'http://dummyimage.com/112x74,',
                'http://dummyimage.com/112x74,',
                'http://dummyimage.com/112x74,'
            ]
        };

        response.render('news/local.html', data);
    });
}
139659
private static void combineWords(Vertex[] wordNet, int start, int end, CoreDictionary.Attribute value)
    {
        if (start + 1 == end)   // 小优化，如果只有一个词，那就不需要合并，直接应用新属性
        {
            wordNet[start].attribute = value;
        }
        else
        {
            StringBuilder sbTerm = new StringBuilder();
            for (int j = start; j < end; ++j)
            {
                if (wordNet[j] == null) continue;
                String realWord = wordNet[j].realWord;
                sbTerm.append(realWord);
                wordNet[j] = null;
            }
            wordNet[start] = new Vertex(sbTerm.toString(), value);
        }
    }