English 中文(简体)
Java 优化: 什么工具可以用来描述顺序的划分?
原标题:Javascript optimization: What tool can condense sequential string concatenations?

这是一个简化的例子,但我正在从事一个编码翻译的工作,该翻译产出是编外文。 由于教学方式,我不得不将翻译成文。 页: 1 最后,我收到一份java书写文件,与以下文件相似,但更长:

function coolfunc() {
    var result = "";
    greet = function(user,town) {
        var output =   ;
        output +=  Welcome   + user +  ! ;
        output +=  How is the weather in   + town +  ? ;
        return output;
    }
    goobye = function(user,town) {
        var output =   ;
        output +=  Farewell   + user +  ! ;
        output +=  Enjoy the weather in   + town +  ! ;
        return output;
    }
    result += "Some output 1";
    result += "Some output 2";
    result += greet("Larry","Cool town");
    result += goobye("Larry","Cool town");
    return result;
}

是否有任何后处理者,我可以用来将上述内容整理成如下内容:

function coolfunc() {
    greet = function(user,town) {
        var output =  Welcome   + user +  ! + How is the weather in   + town +  ? ;
        return output;
    }
    goobye = function(user,town) {
        var output =  Farewell   + user +  ! + Enjoy the weather in   + town +  ! ;
        return output;
    }
    var result = "Some output 1"+"Some output 2"+greet("Larry","Cool town")+goobye("Larry","Cool town");
    return result;
}

如果它能够将邻近的固定扼杀物组合起来,那将是gra。

我估计,劳教或封闭式编辑会这样做,但我可以告诉他们。


Edit:

至今为止的评论意见似乎告诉我翻译部门这样做。 我认为,这不是最佳选择,因为它将使阅读翻译变得非常困难......类似于为什么人们写好字典,然后把它min为生产。

最佳回答

如果出现这种情况,它会像关闭汇编者那样,在修订1576时(http://code.google.com/p/closure-compiler/source/detail?r=1576)处理。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签