Skip to content

Commit

Permalink
Use function reference instead of defining a function for Math.ceil a…
Browse files Browse the repository at this point in the history
…nd Math.max.
  • Loading branch information
dumganhar committed Aug 12, 2024
1 parent 8306c3a commit 5035f0b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
15 changes: 12 additions & 3 deletions cocos/core/global-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,26 @@ const _global = typeof window === 'undefined' ? global : window;
* Cocos引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。
* @deprecated
*/
export const legacyCC: Record<string, any> & {
export const cclegacy: Record<string, any> & {
_global: typeof globalThis;
} = {
_global,
};

/**
* @en
* The main namespace of Cocos engine, all engine core classes, functions, properties and constants are defined in this namespace.
* @zh
* Cocos引擎的主要命名空间,引擎代码中所有的类,函数,属性和常量都在这个命名空间中定义。
* @deprecated
*/
export const legacyCC = cclegacy;

// For internal usage
legacyCC.internal = {};
cclegacy.internal = {};

if (DEV) {
legacyCC._Test = {};
cclegacy._Test = {};
}

const engineVersion = '3.8.4';
Expand Down
2 changes: 1 addition & 1 deletion cocos/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export * from './curves';
export * from './settings';
export * from './system';
export * from './algorithm';
export { legacyCC as cclegacy } from './global-exports';
export { cclegacy } from './global-exports';
export * from './curves/bezier';

// TODO: should not include engine internal exports when module mechanism is implemented.
Expand Down
4 changes: 1 addition & 3 deletions cocos/gfx/base/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2161,9 +2161,7 @@ export function IsPowerOf2 (x: number): boolean {
return x > 0 && (x & (x - 1)) === 0;
}

function ceil (x: number): number {
return Math.ceil(x);
}
const ceil = Math.ceil;

/**
* @en Get memory size of the specified fomat.
Expand Down
4 changes: 1 addition & 3 deletions cocos/gfx/webgl/webgl-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ import { WebGLConstants } from '../gl-constants';
import { assertID, debugID, error, errorID } from '../../core/platform/debug';
import { cclegacy } from '../../core/global-exports';

function max (a: number, b: number): number {
return Math.max(a, b);
}
const max = Math.max;

export function GFXFormatToWebGLType (format: Format, gl: WebGLRenderingContext): GLenum {
switch (format) {
Expand Down

0 comments on commit 5035f0b

Please sign in to comment.