Skip to content

Commit 949a332

Browse files
committed
remove some unused stuff
1 parent 55ef2d4 commit 949a332

File tree

2 files changed

+6
-40
lines changed

2 files changed

+6
-40
lines changed

packages/svelte/src/compiler/phases/1-parse/read/context.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
/** @import { Location } from 'locate-character' */
22
/** @import { Pattern } from 'estree' */
33
/** @import { Parser } from '../index.js' */
4-
import {
5-
is_bracket_open,
6-
is_bracket_close,
7-
get_bracket_close,
8-
match_bracket
9-
} from '../utils/bracket.js';
4+
import { match_bracket } from '../utils/bracket.js';
105
import { parse_expression_at } from '../acorn.js';
116
import { regex_not_newline_characters } from '../../patterns.js';
127
import * as e from '../../../errors.js';
@@ -38,7 +33,9 @@ export default function read_pattern(parser) {
3833
};
3934
}
4035

41-
if (!is_bracket_open(parser.template[i])) {
36+
const char = parser.template[i];
37+
38+
if (char !== '{' && char !== '[') {
4239
e.expected_pattern(i);
4340
}
4441

packages/svelte/src/compiler/phases/1-parse/utils/bracket.js

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,6 @@
11
/** @import { Parser } from '../index.js' */
22
import * as e from '../../../errors.js';
33

4-
const SQUARE_BRACKET_OPEN = '[';
5-
const SQUARE_BRACKET_CLOSE = ']';
6-
const CURLY_BRACKET_OPEN = '{';
7-
const CURLY_BRACKET_CLOSE = '}';
8-
const PARENTHESES_OPEN = '(';
9-
const PARENTHESES_CLOSE = ')';
10-
11-
/** @param {string} char */
12-
export function is_bracket_open(char) {
13-
return char === SQUARE_BRACKET_OPEN || char === CURLY_BRACKET_OPEN;
14-
}
15-
16-
/** @param {string} char */
17-
export function is_bracket_close(char) {
18-
return char === SQUARE_BRACKET_CLOSE || char === CURLY_BRACKET_CLOSE;
19-
}
20-
21-
/** @param {string} open */
22-
export function get_bracket_close(open) {
23-
if (open === SQUARE_BRACKET_OPEN) {
24-
return SQUARE_BRACKET_CLOSE;
25-
}
26-
27-
if (open === CURLY_BRACKET_OPEN) {
28-
return CURLY_BRACKET_CLOSE;
29-
}
30-
31-
if (open === PARENTHESES_OPEN) {
32-
return PARENTHESES_CLOSE;
33-
}
34-
}
35-
364
/**
375
* @param {number} num
386
* @returns {number} Infinity if {@link num} is negative, else {@link num}.
@@ -124,7 +92,7 @@ function count_leading_backslashes(string, search_start_index) {
12492
* @returns {number | undefined} The index of the closing bracket, or undefined if not found.
12593
*/
12694
export function find_matching_bracket(template, index, open) {
127-
const close = get_bracket_close(open);
95+
const close = default_brackets[open];
12896
let brackets = 1;
12997
let i = index;
13098
while (brackets > 0 && i < template.length) {
@@ -166,6 +134,7 @@ export function find_matching_bracket(template, index, open) {
166134
return undefined;
167135
}
168136

137+
/** @type {Record<string, string>} */
169138
const default_brackets = {
170139
'{': '}',
171140
'(': ')',

0 commit comments

Comments
 (0)