GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — os: improve network interface performance · nodejs/node@594bb9d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • os.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/os.js‎

Copy file name to clipboardExpand all lines: lib/os.js
+21-12Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const {
2828
ObjectDefineProperties,
2929
StringPrototypeEndsWith,
3030
StringPrototypeSlice,
31-
StringPrototypeSplit,
3231
SymbolToPrimitive,
3332
} = primordials;
3433

@@ -225,28 +224,38 @@ function getCIDR(address, netmask, family) {
225224
let range = 10;
226225
let groupLength = 8;
227226
let hasZeros = false;
227+
let lastPos = 0;
228228

229229
if (family === 'IPv6') {
230230
split = ':';
231231
range = 16;
232232
groupLength = 16;
233233
}
234234

235-
const parts = StringPrototypeSplit(netmask, split);
236-
for (let i = 0; i < parts.length; i++) {
237-
if (parts[i] !== '') {
238-
const binary = NumberParseInt(parts[i], range);
239-
const tmp = countBinaryOnes(binary);
240-
ones += tmp;
235+
for (let i = 0; i < netmask.length; i++) {
236+
if (netmask[i] !== split) {
237+
if (i + 1 < netmask.length) {
238+
continue;
239+
}
240+
i++;
241+
}
242+
const part = StringPrototypeSlice(netmask, lastPos, i);
243+
lastPos = i + 1;
244+
if (part !== '') {
241245
if (hasZeros) {
242-
if (tmp !== 0) {
246+
if (part !== '0') {
243247
return null;
244248
}
245-
} else if (tmp !== groupLength) {
246-
if ((binary & 1) !== 0) {
247-
return null;
249+
} else {
250+
const binary = NumberParseInt(part, range);
251+
const binaryOnes = countBinaryOnes(binary);
252+
ones += binaryOnes;
253+
if (binaryOnes !== groupLength) {
254+
if ((binary & 1) !== 0) {
255+
return null;
256+
}
257+
hasZeros = true;
248258
}
249-
hasZeros = true;
250259
}
251260
}
252261
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.