Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Avoid UTF8 to UTF16 character offset conversions #63

Closed
wants to merge 10 commits into from
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ addons:
- g++-4.8

node_js:
- "iojs"
- "node"
- "0.10"
- "0.12"

install:
- export CXX=g++-4.8
Expand Down
57 changes: 0 additions & 57 deletions Gruntfile.coffee

This file was deleted.

39 changes: 0 additions & 39 deletions benchmark/benchmark.coffee

This file was deleted.

57 changes: 57 additions & 0 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env node

const fs = require('fs')
const path = require('path')
const {OnigScanner} = require('..')

function runBenchmarkSync (lines, scanner) {
let startTime = Date.now()
let matches = 0

for (let row = 0, rowCount = lines.length; row < rowCount; row++) {
const line = lines[row]
for (let position = 0, length = line.length; position <= length; position++) {
if (scanner.findNextMatchSync(line, position)) matches++
}
}

console.log(`sync: ${matches} matches in ${Date.now() - startTime}ms`)
}

function runBenchmarkAsync (lines, scanner) {
let matches = 0
let callsInProgress = 0

function callback (error, match) {
if (match != null) { matches++ }
if (--callsInProgress === 0) {
console.log(`async: ${matches} matches in ${Date.now() - startTime}ms`)
}
};

var startTime = Date.now()
for (let row = 0, rowCount = lines.length; row < rowCount; row++) {
const line = lines[row]
for (let position = 0, length = line.length; position <= length; position++) {
callsInProgress++
scanner.findNextMatch(line, position, callback)
}
}
}

console.log('oneline.js')
runBenchmarkSync(
fs.readFileSync(path.join(__dirname, 'oneline.js'), 'utf8').split('\n'),
new OnigScanner(['\\[', '\\]', '\\{', '\\}'])
)

console.log('large.js')
runBenchmarkSync(
fs.readFileSync(path.join(__dirname, 'large.js'), 'utf8').split('\n'),
new OnigScanner(['this', 'var', 'selector', 'window'])
)

runBenchmarkAsync(
fs.readFileSync(path.join(__dirname, 'large.js'), 'utf8').split('\n'),
new OnigScanner(['this', 'var', 'selector', 'window'])
)
17 changes: 4 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"main": "./lib/oniguruma.js",
"main": "./src/oniguruma.js",
"name": "oniguruma",
"description": "oniguruma regular expression library",
"version": "6.1.1",
"version": "6.2.0-1",
"licenses": [
{
"type": "MIT",
Expand All @@ -26,22 +26,13 @@
],
"devDependencies": {
"async": "~0.9.0",
"coffee-script": "~1.9.1",
"coffeelint": "~1.9.2",
"grunt": "~0.4.5",
"grunt-cli": "~0.1.13",
"grunt-coffeelint": "0.0.13",
"grunt-contrib-coffee": "~0.13.0",
"grunt-shell": "~1.1.2",
"jasmine-focused": "~1.0.7",
"node-cpplint": "~0.4.0"
"jasmine-focused": "~1.0.7"
},
"dependencies": {
"nan": "^2.0.9"
},
"scripts": {
"prepublish": "grunt publish",
"test": "grunt test",
"test": "jasmine-focused --captureExceptions spec/*",
"benchmark": "benchmark/benchmark.coffee"
}
}
173 changes: 0 additions & 173 deletions spec/onig-reg-exp-spec.coffee

This file was deleted.

Loading