易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : javascript

[翻译]High Performance JavaScript(014)

Recursion Patterns  递归模式
    When you run into a call stack size limit, your first step should be to identify any instances of recursion in the code. To that end, there are two recursive patterns to be aware of. The first is the straightforward recursive pattern represented in the factorial() function shown earlier, when a function calls itself. The general pattern is as follows:
    当你陷入调用栈尺寸限制时,第一步应该定位在代码中的递归实例上。为此,有两个递归模式值得注意。首先是直接递归模式为代表的前面提到的factorial()函数,即一个函数调用自身。其一般模式如下:
function recurse(){
  recurse();
}
recurse();
    This pattern is typically easy to identify when errors occur. A second, subtler pattern involves two functions:
    当发生错误时,这种模式比较容易定位。另外一种模式称为精巧模式,它包含两个函数:
function first(){
  second();
}
function second(){
  first();
}
first();
  & ......

[翻译]High Performance JavaScript(015)

第五章  Strings and Regular Expressions  字符串和正则表达式
    Practically all JavaScript programs are intimately tied to strings. For example, many applications use Ajax to fetch strings from a server, convert those strings into more easily usable JavaScript objects, and then generate strings of HTML from the data. A typical program deals with numerous tasks like these that require you to merge, split, rearrange, search, iterate over, and otherwise handle strings; and as web applications become more complex, progressively more of this processing is done in the browser.
    几乎所有JavaScript程序都与字符串操作紧密相连。例如,许多应用程序使用Ajax从服务器获取字符串,将这些字符串转换成更易用的JavaScript对象,然后从数据中生成HTML字符串。一个典型的程序需要处理若干这样的任务,合并,分解,重新排列,搜索,遍历,以及其他方法处理字符串。随着网页应用越来越复杂,越来越多的此类任务将在浏览器中完成。
    In JavaScript, regular expressions ar ......

[翻译]High Performance JavaScript(016)

Regular Expression Optimization  正则表达式优化
    Incautiously crafted regexes can be a major performance bottleneck (the upcoming section, "Runaway Backtracking" on page 91, contains several examples showing how severe this can be), but there is a lot you can do to improve regex efficiency. Just because two regexes match the same text doesn't mean they do so at the same speed.
    粗浅地编写正则表达式是造成性能瓶颈的主要原因(后面“回溯失控”一节有一些例子说明这是多么严重的问题),但还有很多可以改进正则表达式效率的地方。两个正则表达式匹配相同的文本并不意味着他们具有同等的速度。
    Many factors affect a regex's efficiency. For starters, the text a regex is applied to makes a big difference because regexes spend more time on partial matches than obvious nonmatches. Each browser's regex engine also has different internal optimizations.
    许多因素影响正则表达式的效率。首先,正则表达式适配的文本千差万别,部 ......

[翻译]High Performance JavaScript(017)

A Note on Benchmarking  测试基准说明
    Because a regex's performance can be wildly different depending on the text it's applied to, there's no straightforward way to benchmark regexes against each other. For the best result, you need to benchmark your regexes on test strings of varying lengths that match, don't match, and nearly match.
    因为正则表达式性能因应用文本不同而产生很大差异,没有简单明了的方法可以测试正则表达式之间的性能差别。为得到最好的结果,你需要在各种字符串上测试你的正则表达式,包括不同长度,能够匹配的,不能匹配的,和近似匹配的。
    That's one reason for this chapter's lengthy backtracking coverage. Without a firm understanding of backtracking, you won't be able to anticipate and identify backtracking-related problems. To help you catch runaway backtracking early, always test your regexes with long strings that contain partial matches. Think about the kinds of strings that your regexes will nearly but not quite ma ......

[翻译]High Performance JavaScript(018)

String Trimming  字符串修剪
    Removing leading and trailing whitespace from a string is a simple but common task. Although ECMAScript 5 adds a native string trim method (and you should therefore start to see this method in upcoming browsers), JavaScript has not historically included it. For the current browser crop, it's still necessary to implement a trim method yourself or rely on a library that includes it.
    去除字符串首尾的空格是一个简单而常见的任务。虽然ECMAScript 5添加了原生字符串修剪函数(你应该可以在即将出现的浏览器中看到它们),到目前为止JavaScript还没有包含它。对当前的浏览器而言,有必要自己实现一个修剪函数,或者依靠一个包含此功能的库。
    Trimming strings is not a common performance bottleneck, but it serves as a decent case study for regex optimization since there are a variety of ways to implement it.
    修剪字符串不是一个常见的性能瓶颈,但作为学习正则表达式优化的例子有多种实现方法。
Trimming with ......

[翻译]High Performance JavaScript(019)

第六章  Responsive Interfaces  响应接口
    There's nothing more frustrating than clicking something on a web page and having nothing happen. This problem goes back to the origin of transactional web applications and resulted in the now-ubiquitous "please click only once" message that accompanies most form submissions. A user's natural inclination is to repeat any action that doesn't result in an obvious change, and so ensuring responsiveness in web applications is an important performance concern.
    没有什么比点击页面上的东西却什么也没发生更令人感到挫折了。这个问题又回到了原始网页交互程序和现在已无处不在的提交表单时弹出的“请勿重复提交”消息上面。用户自然倾向于重复尝试这些不发生明显变化的动作,所以确保网页应用程序的响应速度也是一个重要的性能关注点。
    Chapter 1 introduced the browser UI thread concept. As a recap, most browsers have a single process that is shared between JavaScript execution and user interface up ......
总记录数:2244; 总页数:374; 每页6 条; 首页 上一页 [3] [4] [5] [6] 7 [8] [9] [10] [11] [12]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号