Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c09b5ff2
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
GitCode(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c09b5ff2
编写于
3月 23, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Initial perf investigation
上级
3604a189
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
153 addition
and
60 deletion
+153
-60
scripts/code-perf.bat
scripts/code-perf.bat
+28
-0
src/vs/base/common/eventEmitter.ts
src/vs/base/common/eventEmitter.ts
+1
-1
src/vs/base/common/strings.ts
src/vs/base/common/strings.ts
+1
-0
src/vs/editor/browser/view/viewLayer.ts
src/vs/editor/browser/view/viewLayer.ts
+50
-32
src/vs/editor/browser/view/viewOverlays.ts
src/vs/editor/browser/view/viewOverlays.ts
+15
-2
src/vs/editor/browser/viewParts/lines/viewLine.ts
src/vs/editor/browser/viewParts/lines/viewLine.ts
+4
-1
src/vs/editor/common/model/modelLine.ts
src/vs/editor/common/model/modelLine.ts
+45
-23
src/vs/editor/common/model/textModelWithTokens.ts
src/vs/editor/common/model/textModelWithTokens.ts
+3
-0
src/vs/editor/common/modes/supports.ts
src/vs/editor/common/modes/supports.ts
+2
-1
src/vs/editor/common/viewModel/characterHardWrappingLineMapper.ts
...ditor/common/viewModel/characterHardWrappingLineMapper.ts
+4
-0
未找到文件。
scripts/code-perf.bat
0 → 100644
浏览文件 @
c09b5ff2
@echo
off
setlocal
title
VSCode
Dev
pushd
%~dp0
\..
:: Node modules
if
not
exist
node_modules
call
.\scripts\npm.bat
install
:: Get electron
node
.\node_modules\gulp\bin\gulp.js
electron
:: Build
if
not
exist
out
node
.\node_modules\gulp\bin\gulp.js
compile
:: Configuration
set
NODE_ENV
=
development
set
VSCODE_DEV
=
1
set
ELECTRON_DEFAULT_ERROR_MODE
=
1
set
ELECTRON_ENABLE_LOGGING
=
1
set
ELECTRON_ENABLE_STACK_DUMPING
=
1
:: Launch Code
.\.build\electron\electron.exe .
%
*
--no-sandbox --js-flags
=
"--trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces"
popd
endlocal
\ No newline at end of file
src/vs/base/common/eventEmitter.ts
浏览文件 @
c09b5ff2
...
...
@@ -18,7 +18,7 @@ export class EmitterEvent implements IEmitterEvent {
private
_data
:
any
;
private
_emitterType
:
string
;
constructor
(
eventType
:
string
,
data
:
any
,
emitterType
:
string
=
null
)
{
constructor
(
eventType
:
string
=
null
,
data
:
any
=
null
,
emitterType
:
string
=
null
)
{
this
.
_type
=
eventType
;
this
.
_data
=
data
;
this
.
_emitterType
=
emitterType
;
...
...
src/vs/base/common/strings.ts
浏览文件 @
c09b5ff2
...
...
@@ -455,6 +455,7 @@ export function isFullWidthCharacter(charCode:number): boolean {
// of which FF01 - FF5E fullwidth ASCII of 21 to 7E
// [IGNORE] and FF65 - FFDC halfwidth of Katakana and Hangul
// [IGNORE] FFF0 — FFFF Specials
charCode
=
+
charCode
;
// @perf
return
(
(
charCode
>=
0x2E80
&&
charCode
<=
0xD7AF
)
||
(
charCode
>=
0xF900
&&
charCode
<=
0xFAFF
)
...
...
src/vs/editor/browser/view/viewLayer.ts
浏览文件 @
c09b5ff2
...
...
@@ -492,8 +492,55 @@ class ViewLayerRenderer {
ctx
.
lines
.
splice
(
removeIndex
,
removeCount
);
}
private
static
_resolveInlineDecorations
(
ctx
:
IRendererContext
):
editorCommon
.
IModelDecoration
[][]
{
let
result
:
editorCommon
.
IModelDecoration
[][]
=
[];
for
(
let
i
=
0
,
len
=
ctx
.
linesLength
;
i
<
len
;
i
++
)
{
let
lineNumber
=
i
+
ctx
.
rendLineNumberStart
;
result
[
i
]
=
ctx
.
getInlineDecorationsForLineInViewport
(
lineNumber
);
}
return
result
;
}
private
_finishRenderingNewLines
(
ctx
:
IRendererContext
,
domNodeIsEmpty
:
boolean
,
newLinesHTML
:
string
[],
wasNew
:
boolean
[]):
void
{
var
lastChild
=
<
HTMLElement
>
ctx
.
domNode
.
lastChild
;
if
(
domNodeIsEmpty
||
!
lastChild
)
{
ctx
.
domNode
.
innerHTML
=
this
.
_extraDomNodeHTML
()
+
newLinesHTML
.
join
(
''
);
}
else
{
lastChild
.
insertAdjacentHTML
(
'
afterend
'
,
newLinesHTML
.
join
(
''
));
}
var
currChild
=
<
HTMLElement
>
ctx
.
domNode
.
lastChild
;
for
(
let
i
=
ctx
.
linesLength
-
1
;
i
>=
0
;
i
--
)
{
let
line
=
ctx
.
lines
[
i
];
if
(
wasNew
[
i
])
{
line
.
setDomNode
(
currChild
);
currChild
=
<
HTMLElement
>
currChild
.
previousSibling
;
}
}
}
private
_finishRenderingInvalidLines
(
ctx
:
IRendererContext
,
invalidLinesHTML
:
string
[],
wasInvalid
:
boolean
[]):
void
{
var
hugeDomNode
=
document
.
createElement
(
'
div
'
);
hugeDomNode
.
innerHTML
=
invalidLinesHTML
.
join
(
''
);
var
lineDomNode
:
HTMLElement
,
source
:
HTMLElement
;
for
(
let
i
=
0
;
i
<
ctx
.
linesLength
;
i
++
)
{
let
line
=
ctx
.
lines
[
i
];
if
(
wasInvalid
[
i
])
{
source
=
<
HTMLElement
>
hugeDomNode
.
firstChild
;
lineDomNode
=
line
.
getDomNode
();
lineDomNode
.
parentNode
.
replaceChild
(
source
,
lineDomNode
);
line
.
setDomNode
(
source
);
}
}
}
private
_finishRendering
(
ctx
:
IRendererContext
,
domNodeIsEmpty
:
boolean
,
deltaTop
:
number
[]):
void
{
let
inlineDecorations
=
ViewLayerRenderer
.
_resolveInlineDecorations
(
ctx
);
var
i
:
number
,
len
:
number
,
line
:
IVisibleLineData
,
...
...
@@ -509,7 +556,7 @@ class ViewLayerRenderer {
line
=
ctx
.
lines
[
i
];
lineNumber
=
i
+
ctx
.
rendLineNumberStart
;
if
(
line
.
shouldUpdateHTML
(
lineNumber
,
ctx
.
getInlineDecorationsForLineInViewport
(
lineNumber
)
))
{
if
(
line
.
shouldUpdateHTML
(
lineNumber
,
inlineDecorations
[
i
]
))
{
var
lineDomNode
=
line
.
getDomNode
();
if
(
!
lineDomNode
)
{
// Line is new
...
...
@@ -527,40 +574,11 @@ class ViewLayerRenderer {
}
if
(
hadNewLine
)
{
var
lastChild
=
<
HTMLElement
>
ctx
.
domNode
.
lastChild
;
if
(
domNodeIsEmpty
||
!
lastChild
)
{
ctx
.
domNode
.
innerHTML
=
this
.
_extraDomNodeHTML
()
+
newLinesHTML
.
join
(
''
);
}
else
{
lastChild
.
insertAdjacentHTML
(
'
afterend
'
,
newLinesHTML
.
join
(
''
));
}
var
currChild
=
<
HTMLElement
>
ctx
.
domNode
.
lastChild
;
for
(
i
=
ctx
.
linesLength
-
1
;
i
>=
0
;
i
--
)
{
line
=
ctx
.
lines
[
i
];
if
(
wasNew
[
i
])
{
line
.
setDomNode
(
currChild
);
currChild
=
<
HTMLElement
>
currChild
.
previousSibling
;
}
}
this
.
_finishRenderingNewLines
(
ctx
,
domNodeIsEmpty
,
newLinesHTML
,
wasNew
);
}
if
(
hadInvalidLine
)
{
var
hugeDomNode
=
document
.
createElement
(
'
div
'
);
hugeDomNode
.
innerHTML
=
invalidLinesHTML
.
join
(
''
);
var
lineDomNode
:
HTMLElement
,
source
:
HTMLElement
;
for
(
i
=
0
;
i
<
ctx
.
linesLength
;
i
++
)
{
line
=
ctx
.
lines
[
i
];
if
(
wasInvalid
[
i
])
{
source
=
<
HTMLElement
>
hugeDomNode
.
firstChild
;
lineDomNode
=
line
.
getDomNode
();
lineDomNode
.
parentNode
.
replaceChild
(
source
,
lineDomNode
);
line
.
setDomNode
(
source
);
}
}
this
.
_finishRenderingInvalidLines
(
ctx
,
invalidLinesHTML
,
wasInvalid
);
}
}
}
...
...
src/vs/editor/browser/view/viewOverlays.ts
浏览文件 @
c09b5ff2
...
...
@@ -126,14 +126,27 @@ class ViewOverlayLine implements IVisibleLineData {
}
private
_piecesEqual
(
newPieces
:
string
[]):
boolean
{
if
(
!
this
.
_renderPieces
||
this
.
_renderPieces
.
length
!==
newPieces
.
length
)
{
if
(
!
this
.
_renderPieces
)
{
return
false
;
}
for
(
var
i
=
0
,
len
=
newPieces
.
length
;
i
<
len
;
i
++
)
{
let
myLen
=
this
.
_renderPieces
.
length
;
let
newLen
=
newPieces
.
length
;
if
(
myLen
!==
newLen
)
{
return
false
;
}
if
(
newLen
===
0
)
{
return
true
;
}
for
(
let
i
=
0
;
i
<
newLen
;
i
++
)
{
if
(
this
.
_renderPieces
[
i
]
!==
newPieces
[
i
])
{
return
false
;
}
}
return
true
;
}
...
...
src/vs/editor/browser/viewParts/lines/viewLine.ts
浏览文件 @
c09b5ff2
...
...
@@ -168,7 +168,10 @@ export class ViewLine implements IVisibleLineData {
* Visible ranges for a model range
*/
public
getVisibleRangesForRange
(
startColumn
:
number
,
endColumn
:
number
,
clientRectDeltaLeft
:
number
,
endNode
:
HTMLElement
):
HorizontalRange
[]
{
let
stopRenderingLineAfter
=
this
.
_context
.
configuration
.
editor
.
stopRenderingLineAfter
;
startColumn
=
+
startColumn
;
// @perf
endColumn
=
+
endColumn
;
// @perf
clientRectDeltaLeft
=
+
clientRectDeltaLeft
;
// @perf
let
stopRenderingLineAfter
=
+
this
.
_context
.
configuration
.
editor
.
stopRenderingLineAfter
;
// @perf
if
(
stopRenderingLineAfter
!==
-
1
&&
startColumn
>
stopRenderingLineAfter
&&
endColumn
>
stopRenderingLineAfter
)
{
// This range is obviously not visible
...
...
src/vs/editor/common/model/modelLine.ts
浏览文件 @
c09b5ff2
...
...
@@ -80,6 +80,10 @@ export class ModelLine {
this
.
lineNumber
=
lineNumber
;
this
.
text
=
text
;
this
.
isInvalid
=
false
;
this
.
_state
=
null
;
this
.
_modeTransitions
=
null
;
this
.
_lineTokens
=
null
;
this
.
_markers
=
null
;
}
// --- BEGIN STATE
...
...
@@ -123,12 +127,27 @@ export class ModelLine {
// --- BEGIN TOKENS
public
setTokens
(
map
:
ITokensInflatorMap
,
tokens
:
IToken
[],
topLevelMode
:
IMode
,
modeTransitions
:
IModeTransition
[]):
void
{
this
.
_setLineTokens
(
map
,
tokens
);
this
.
_setLineTokens
FromInflated
(
map
,
tokens
);
this
.
_setModeTransitions
(
topLevelMode
,
modeTransitions
);
}
private
_setLineTokens
(
map
:
ITokensInflatorMap
,
tokens
:
IToken
[]
|
number
[]):
void
{
let
desired
=
toLineTokens
(
map
,
tokens
,
this
.
text
.
length
);
private
_setLineTokensFromInflated
(
map
:
ITokensInflatorMap
,
tokens
:
IToken
[]):
void
{
let
desired
=
toLineTokensFromInflated
(
map
,
tokens
,
this
.
text
.
length
);
if
(
desired
===
null
)
{
// saving memory
if
(
typeof
this
.
_lineTokens
===
'
undefined
'
)
{
return
;
}
this
.
_lineTokens
=
null
;
return
;
}
this
.
_lineTokens
=
desired
;
}
private
_setLineTokensFromDeflated
(
map
:
ITokensInflatorMap
,
tokens
:
number
[]):
void
{
let
desired
=
toLineTokensFromDeflated
(
map
,
tokens
,
this
.
text
.
length
);
if
(
desired
===
null
)
{
// saving memory
...
...
@@ -238,7 +257,7 @@ export class ModelLine {
tokens
.
pop
();
}
this
.
_setLineTokens
(
map
,
tokens
);
this
.
_setLineTokens
FromDeflated
(
map
,
tokens
);
}
}
...
...
@@ -491,10 +510,10 @@ export class ModelLine {
let
myLineTokens
=
this
.
_lineTokens
;
if
(
myLineTokens
)
{
// I have real tokens
this
.
_setLineTokens
(
myLineTokens
.
getBinaryEncodedTokensMap
(),
myLineTokens
.
getBinaryEncodedTokens
().
concat
(
otherTokens
));
this
.
_setLineTokens
FromDeflated
(
myLineTokens
.
getBinaryEncodedTokensMap
(),
myLineTokens
.
getBinaryEncodedTokens
().
concat
(
otherTokens
));
}
else
{
// I don't have real tokens
this
.
_setLineTokens
(
otherLineTokens
.
getBinaryEncodedTokensMap
(),
otherTokens
);
this
.
_setLineTokens
FromDeflated
(
otherLineTokens
.
getBinaryEncodedTokensMap
(),
otherTokens
);
}
}
...
...
@@ -641,11 +660,24 @@ export class ModelLine {
}
}
function
areDeflatedTokens
(
tokens
:
IToken
[]
|
number
[]):
tokens
is
number
[]
{
return
(
typeof
tokens
[
0
]
===
'
number
'
);
function
toLineTokensFromInflated
(
map
:
ITokensInflatorMap
,
tokens
:
IToken
[],
textLength
:
number
):
ILineTokens
{
if
(
textLength
===
0
)
{
return
null
;
}
if
(
!
tokens
||
tokens
.
length
===
0
)
{
return
null
;
}
if
(
tokens
.
length
===
1
)
{
if
(
tokens
[
0
].
startIndex
===
0
&&
tokens
[
0
].
type
===
''
)
{
return
null
;
}
}
let
deflated
=
LineTokensBinaryEncoding
.
deflateArr
(
map
,
tokens
);
return
new
LineTokens
(
map
,
deflated
);
}
function
toLineTokens
(
map
:
ITokensInflatorMap
,
tokens
:
IToken
[]
|
number
[],
textLength
:
number
):
ILineTokens
{
function
toLineTokens
FromDeflated
(
map
:
ITokensInflatorMap
,
tokens
:
number
[],
textLength
:
number
):
ILineTokens
{
if
(
textLength
===
0
)
{
return
null
;
}
...
...
@@ -653,14 +685,8 @@ function toLineTokens(map:ITokensInflatorMap, tokens:IToken[]|number[], textLeng
return
null
;
}
if
(
tokens
.
length
===
1
)
{
if
(
areDeflatedTokens
(
tokens
))
{
if
(
tokens
[
0
]
===
0
)
{
return
null
;
}
}
else
{
if
(
tokens
[
0
].
startIndex
===
0
&&
tokens
[
0
].
type
===
''
)
{
return
null
;
}
if
(
tokens
[
0
]
===
0
)
{
return
null
;
}
}
return
new
LineTokens
(
map
,
tokens
);
...
...
@@ -675,13 +701,9 @@ export class LineTokens implements ILineTokens {
private
map
:
ITokensInflatorMap
;
private
_tokens
:
number
[];
constructor
(
map
:
ITokensInflatorMap
,
tokens
:
IToken
[]
|
number
[])
{
constructor
(
map
:
ITokensInflatorMap
,
tokens
:
/*IToken[]|*/
number
[])
{
this
.
map
=
map
;
if
(
areDeflatedTokens
(
tokens
))
{
this
.
_tokens
=
tokens
;
}
else
{
this
.
_tokens
=
LineTokensBinaryEncoding
.
deflateArr
(
map
,
tokens
);
}
this
.
_tokens
=
tokens
;
}
public
toString
():
string
{
...
...
src/vs/editor/common/model/textModelWithTokens.ts
浏览文件 @
c09b5ff2
...
...
@@ -217,6 +217,9 @@ export class TextModelWithTokens extends TextModel implements editorCommon.IToke
this
.
_stopLineTokenizationAfter
=
DefaultConfig
.
editor
.
stopLineTokenizationAfter
;
this
.
_modeListener
=
null
;
this
.
_modeToModelBinder
=
null
;
if
(
!
modeOrPromise
)
{
this
.
_mode
=
new
NullMode
();
}
else
if
(
TPromise
.
is
(
modeOrPromise
))
{
...
...
src/vs/editor/common/modes/supports.ts
浏览文件 @
c09b5ff2
...
...
@@ -140,8 +140,9 @@ export class FilteredLineContext implements modes.ILineContext {
}
}
const
IGNORE_IN_TOKENS
=
/
\b(
comment|string|regex
)\b
/
;
export
function
ignoreBracketsInToken
(
tokenType
:
string
):
boolean
{
return
/
\b(
comment|string|regex
)\b
/
.
test
(
tokenType
);
return
IGNORE_IN_TOKENS
.
test
(
tokenType
);
}
// TODO@Martin: find a better home for this code:
...
...
src/vs/editor/common/viewModel/characterHardWrappingLineMapper.ts
浏览文件 @
c09b5ff2
...
...
@@ -57,6 +57,10 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
// TODO@Alex -> duplicated in lineCommentCommand
private
static
nextVisibleColumn
(
currentVisibleColumn
:
number
,
tabSize
:
number
,
isTab
:
boolean
,
columnSize
:
number
):
number
{
currentVisibleColumn
=
+
currentVisibleColumn
;
//@perf
tabSize
=
+
tabSize
;
//@perf
columnSize
=
+
columnSize
;
//@perf
if
(
isTab
)
{
return
currentVisibleColumn
+
(
tabSize
-
(
currentVisibleColumn
%
tabSize
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录