Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 4, 2026. It is now read-only.

⚑ Bolt: [performance improvement] Avoid intermediate buffer in fs.readFileSync calls #32

Draft
vishnu-madhavan-git wants to merge 1 commit into main
base: main
Choose a base branch
Loading
from bolt-fs-readfilesync-optimization-16859852880905722925
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('devices info', () => {
const file = path.join(projectRoot, '.expo', 'devices.json');
expect(fs.existsSync(file)).toBe(true);

const { devices } = JSON.parse(fs.readFileSync(file, 'utf8').toString());
const { devices } = JSON.parse(fs.readFileSync(file, 'utf8'));
expect(devices.length).toBe(1);
expect(devices[0].installationId).toBe('test-device-id');
});
Expand Down
4 changes: 2 additions & 2 deletions packages/@expo/cli/src/utils/mergeGitIgnorePaths.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export function mergeGitIgnorePaths(
return null;
}

const targetGitIgnore = fs.readFileSync(targetGitIgnorePath).toString();
const sourceGitIgnore = fs.readFileSync(sourceGitIgnorePath).toString();
const targetGitIgnore = fs.readFileSync(targetGitIgnorePath, 'utf8');
const sourceGitIgnore = fs.readFileSync(sourceGitIgnorePath, 'utf8');
const merged = mergeGitIgnoreContents(targetGitIgnore, sourceGitIgnore);
// Only rewrite the file if it was modified.
if (merged.contents) {
Expand Down
4 changes: 2 additions & 2 deletions packages/@expo/config-plugins/src/android/Package.ts
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export async function renameJniOnDiskForType({
filesToUpdate.forEach((filepath: string) => {
try {
if (fs.lstatSync(filepath).isFile() && ['.h', '.cpp'].includes(path.extname(filepath))) {
let contents = fs.readFileSync(filepath).toString();
let contents = fs.readFileSync(filepath, 'utf8');
contents = contents.replace(
new RegExp(transformJavaClassDescriptor(currentPackageName).replace(/\//g, '\\/'), 'g'),
transformJavaClassDescriptor(packageName)
Expand Down Expand Up @@ -207,7 +207,7 @@ export async function renamePackageOnDiskForType({
filesToUpdate.forEach((filepath: string) => {
try {
if (fs.lstatSync(filepath).isFile()) {
let contents = fs.readFileSync(filepath).toString();
let contents = fs.readFileSync(filepath, 'utf8');
if (path.extname(filepath) === '.kt') {
contents = replacePackageName(contents, currentPackageName, kotlinSanitizedPackageName);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ public class SomeClass {
await renamePackageOnDisk({ android: { package: 'xyz.bront.app' } }, '/myapp');
const mainActivityPath = '/myapp/android/app/src/main/java/xyz/bront/app/MainActivity.java';
expect(fs.existsSync(mainActivityPath)).toBeTruthy();
expect(fs.readFileSync(mainActivityPath).toString()).toMatch('package xyz.bront.app');
expect(fs.readFileSync(mainActivityPath, 'utf8')).toMatch('package xyz.bront.app');

const nestedClassPath =
'/myapp/android/app/src/main/java/xyz/bront/app/example/SomeClass.java';
expect(fs.existsSync(nestedClassPath)).toBeTruthy();
expect(fs.readFileSync(nestedClassPath).toString()).toMatch('package xyz.bront.app');
expect(fs.readFileSync(nestedClassPath).toString()).not.toMatch('com.lololol');
expect(fs.readFileSync(nestedClassPath, 'utf8')).toMatch('package xyz.bront.app');
expect(fs.readFileSync(nestedClassPath, 'utf8')).not.toMatch('com.lololol');

const buckPath = '/myapp/android/app/BUCK';
expect(fs.readFileSync(buckPath).toString()).toMatch('package = "xyz.bront.app"');
expect(fs.readFileSync(buckPath).toString()).not.toMatch('com.lololol');
expect(fs.readFileSync(buckPath, 'utf8')).toMatch('package = "xyz.bront.app"');
expect(fs.readFileSync(buckPath, 'utf8')).not.toMatch('com.lololol');
});

it('does not clobber itself if package has similar parts', async () => {
await renamePackageOnDisk({ android: { package: 'com.bront' } }, '/myapp');
const mainActivityPath = '/myapp/android/app/src/main/java/com/bront/MainActivity.java';
expect(fs.existsSync(mainActivityPath)).toBeTruthy();
expect(fs.readFileSync(mainActivityPath).toString()).toMatch('package com.bront');
expect(fs.readFileSync(mainActivityPath, 'utf8')).toMatch('package com.bront');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe(setSplashScreenLegacyMainActivity, () => {
},
};
const mainActivity = await AndroidConfig.Paths.getMainActivityAsync('/app');
let contents = fs.readFileSync(mainActivity.path).toString();
let contents = fs.readFileSync(mainActivity.path, 'utf8');
contents = await setSplashScreenLegacyMainActivity(
exp,
{ backgroundColor: '#000020', resizeMode: 'native' },
Expand Down

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /