Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize parse integer list #19627

Closed

Conversation

JohnCoconut
Copy link
Contributor

Same PR (#19619) as the v3 branch. The comment from v3 PR is copied below.

In file cocos/2d/CCSpriteFrameCache.cpp, the function SpriteFrameCache::parseIntegerList calls

res[i++] = atoi(string.substr(start, end - start).c_str());

in a loop, which is bad for performance, as substr() function construct a new string and destruct it in every loop iteration.

The new function use strtol, which does not create new string. It's nearly twice as fast as the old one, according to google benchmark.

http://quick-bench.com/JjzXDobBEloaspNT0nOPC7EO9m4

mars3142 and others added 30 commits October 31, 2018 16:54
Don’t hide the home indicator, instead „disable“ it. So the user has to double tap it to use it. It’s tinted to be nearly invisible over the content.
Bugfix for aviod reading outside of the buffer. If new will allocate memory at the end of the heap - reading of MAX_LOG_LENGTH from memory would cause access violation reading location.
…18993)

* add line spacing support for system font on iOS and Android

* correct para flag

IIIIIIIIZFFFFZIIIIFZI
IIIIIIIIFZFFFFZIIIIFZI
* Add `GLView::setCursor` for desktop platforms

* Add test for custom mouse cursor
* modern cmake, use target_compile_definitions partly

* simplify macro define, remove USE_*

* modern cmake, macro define

* add physics 2d macro define into ccConfig.h

* remove USE_CHIPMUNK macro in build.gradle

* remove CocosSelectModule.cmake

* shrink useless define

* simplify compile options config, re-add if necessary

* update external for tmp CI test

* un-quote target_compile_options value

* add "-g" parameter only when debug mode

* keep single build type when generator Xcode & VS projecy

* update external for tmp CI tes

* add static_cast<char>(-1), fix -Wc++11-narrowing

* simplify win32 compile define

* not modify code, only improve compile options
Just checked for the loading bar target and cast appropriately.

I made this edit in Github, but the source edit was from my old fork that I can't get to merge in tankorsmash/cocos2dx-mytracker@aac2a0b
* cmake_compiler_flags

* Fix typo

* Fix typo2

* Remove chanages from Android.mk
in `BitmapDC::sizeWithText` and `BitmapDC::drawText`, use DT_HIDEPREFIX flag for ignoring the ampersand (&) prefix character in the text.
we don't need to handle ampersands ourselves
refer [MSDN](https://docs.microsoft.com/zh-cn/windows/desktop/api/winuser/nf-winuser-drawtextexw)
* don't add -Wno-deprecated into jsb target

* correct lua template cmake build

* fix win32 lua template compile error
* re-target on wi10 for win32 project

* fix js-tests sources copy

* fix lua tests

* fix js template

* remove libbox2d.vcxproj ref

* improve js source copy

* copy source in post build event

* little improve

* update external
* fix FileUtils::getContents on linux/mac

* use stat.st_mode

* simplify
* fix wrong png convert format from sRGB to Gray

* erase plist index if all frames was erased

* test_A8.png have I8 format, fix it
* trucate label text

* modify log value
* win32 getFileSize

* fix stat
sbrednikhin and others added 24 commits March 15, 2019 11:34
Getting current clearing color in Renderer
Changing tabs to spaces and getters for claring color
…1552959478

[ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically
Ability to change title position
There is an unmatched ");" in the file at line 720.
* Fix bug: can't play video in obbfile.

* Change check order.
The token array shouldn't be static in CCPUScriptTranslator.h,
otherwise including it will generate duplicate token array.
* Update UIDeprecated.cpp

There is no need of this last "}".

* End the NS_CC properly.

Change the "}" with NS_CC_END to avoid misunderstandings.
* add build test option for cmake

* configure build test option for cmake
…sed is a single character string literal. The character literal overload is more efficient. (cocos2d#19614)
@minggo
Copy link
Contributor

minggo commented Apr 19, 2019

Oh, it seems it is a bad PR. You should check out the branch based on metal-support branch, then modify it.

@minggo
Copy link
Contributor

minggo commented Apr 19, 2019

You can do like this:

  • checkout a branch based on metal-support branch
  • use git cherry-pick to check the commit

The commit id may be different from your local commit id, because every PR is merged by rebase.

@JohnCoconut
Copy link
Contributor Author

JohnCoconut commented Apr 19, 2019

@minggo

The commit id may be different from your local commit id, because every PR is merged by rebase.

Sorry, but I am not sure what you mean. I am unfamiliar with git cherry-pick. I just cherry-picked a local commit, pushed it to my fork, and made a PR. No conflict now. Am I doing it right?

#19629

Shall I close this PR if I am doing it correctly. You can close it too if it's ok.

@minggo minggo closed this Apr 19, 2019
@minggo
Copy link
Contributor

minggo commented Apr 19, 2019

The new PR looks good.

@JohnCoconut JohnCoconut deleted the optimize-parseIntegerList branch April 19, 2019 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet