{"action":"created","issue":{"url":"https://api.github.com/repos/peq/WurstScript/issues/379","labels_url":"https://api.github.com/repos/peq/WurstScript/issues/379/labels{/name}","comments_url":"https://api.github.com/repos/peq/WurstScript/issues/379/comments","events_url":"https://api.github.com/repos/peq/WurstScript/issues/379/events","html_url":"https://github.com/peq/WurstScript/issues/379","id":102420792,"number":379,"title":"Optimization: remove function calls without sideeffect","user":{"login":"peq","id":1071762,"avatar_url":"https://avatars.githubusercontent.com/u/1071762?v=3","gravatar_id":"","url":"https://api.github.com/users/peq","html_url":"https://github.com/peq","followers_url":"https://api.github.com/users/peq/followers","following_url":"https://api.github.com/users/peq/following{/other_user}","gists_url":"https://api.github.com/users/peq/gists{/gist_id}","starred_url":"https://api.github.com/users/peq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peq/subscriptions","organizations_url":"https://api.github.com/users/peq/orgs","repos_url":"https://api.github.com/users/peq/repos","events_url":"https://api.github.com/users/peq/events{/privacy}","received_events_url":"https://api.github.com/users/peq/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-08-21T16:53:09Z","updated_at":"2015-08-22T16:43:42Z","closed_at":null,"body":"For example a call like \r\n\r\n```\r\ncall I2S(42)\r\n```\r\n\r\ncould be removed from the output as the result is never used.\r\n\r\n@Frotty has created a list of functions without side-effect:\r\n\r\n```\r\n\t\r\n\r\n    ConvertRace\r\n    ConvertAllianceType\r\n    ConvertRacePref\r\n    ConvertIGameState\r\n    ConvertFGameState\r\n    ConvertPlayerState\r\n    ConvertPlayerScore\r\n    ConvertPlayerGameResult\r\n    ConvertUnitState\r\n    ConvertAIDifficulty\r\n    ConvertGameEvent\r\n    ConvertPlayerEvent\r\n    ConvertPlayerUnitEvent\r\n    ConvertWidgetEvent\r\n    ConvertDialogEvent\r\n    ConvertUnitEvent\r\n    ConvertLimitOp\r\n    ConvertUnitType\r\n    ConvertGameSpeed\r\n    ConvertPlacement\r\n    ConvertStartLocPrio\r\n    ConvertGameDifficulty\r\n    ConvertGameType\r\n    ConvertMapFlag\r\n    ConvertMapVisibility\r\n    ConvertMapSetting\r\n    ConvertMapDensity\r\n    ConvertMapControl\r\n    ConvertPlayerColor\r\n    ConvertPlayerSlotState\r\n    ConvertVolumeGroup\r\n    ConvertCameraField\r\n    ConvertBlendMode\r\n    ConvertRarityControl\r\n    ConvertTexMapFlags\r\n    ConvertFogState\r\n    ConvertEffectType\r\n    ConvertVersion\r\n    ConvertItemType\r\n    ConvertAttackType\r\n    ConvertDamageType\r\n    ConvertWeaponType\r\n    ConvertSoundType\r\n    ConvertPathingType\r\n    OrderId\r\n    OrderId2String\r\n    AbilityId\r\n    AbilityId2String\r\n    GetObjectName\r\n    Deg2Rad\r\n    Rad2Deg\r\n    Sin\r\n    Cos\r\n    Tan\r\n    Asin\r\n    Acos\r\n    Atan\r\n    Atan2\r\n    SquareRoot\r\n    Pow\r\n    I2R\r\n    R2I\r\n    I2S\r\n    R2S\r\n    R2SW\r\n    S2I\r\n    S2R\r\n    GetHandleId\r\n    SubString\r\n    StringLength\r\n    StringCase\r\n    StringHash\r\n    GetLocalizedString\r\n    GetLocalizedHotkey\r\n    GetStartLocPrioSlot\r\n    GetStartLocPrio\r\n    GetTeams\r\n    GetPlayers\r\n    IsGameTypeSupported\r\n    GetGameTypeSelected\r\n    IsMapFlagSet\r\n    GetGamePlacement\r\n    GetGameSpeed\r\n    GetGameDifficulty\r\n    GetResourceDensity\r\n    GetCreatureDensity\r\n    GetStartLocationX\r\n    GetStartLocationY\r\n    GetStartLocationLoc\r\n    GetPlayerTeam\r\n    GetPlayerStartLocation\r\n    GetPlayerColor\r\n    GetPlayerSelectable\r\n    GetPlayerController\r\n    GetPlayerSlotState\r\n    GetPlayerTaxRate\r\n    IsPlayerRacePrefSet\r\n    GetPlayerName\r\n    TimerGetElapsed\r\n    TimerGetRemaining\r\n    TimerGetTimeout\r\n    GetExpiredTimer\r\n    FirstOfGroup\r\n    GetRectCenterX\r\n    GetRectCenterY\r\n    GetRectMinX\r\n    GetRectMinY\r\n    GetRectMaxX\r\n    GetRectMaxY\r\n    GetLocationX\r\n    GetLocationY\r\n    GetLocationZ\r\n    IsUnitInRegion\r\n    IsPointInRegion\r\n    IsLocationInRegion\r\n    GetWorldBounds\r\n    IsTriggerEnabled\r\n    IsTriggerWaitOnSleeps\r\n    GetFilterUnit\r\n    GetEnumUnit\r\n    GetFilterDestructable\r\n    GetEnumDestructable\r\n    GetFilterItem\r\n    GetEnumItem\r\n    GetFilterPlayer\r\n    GetEnumPlayer\r\n    GetTriggeringTrigger\r\n    GetTriggerEventId\r\n    GetTriggerEvalCount\r\n    GetTriggerExecCount\r\n    And\r\n    Or\r\n    Not\r\n    GetEventGameState\r\n    GetWinningPlayer\r\n    GetTriggeringRegion\r\n    GetEnteringUnit\r\n    GetLeavingUnit\r\n    GetTriggeringTrackable\r\n    GetClickedButton\r\n    GetClickedDialog\r\n    GetTournamentFinishSoonTimeRemaining\r\n    GetTournamentFinishNowRule\r\n    GetTournamentFinishNowPlayer\r\n    GetTournamentScore\r\n    GetSaveBasicFilename\r\n    GetTriggerPlayer\r\n    GetLevelingUnit\r\n    GetLearningUnit\r\n    GetLearnedSkill\r\n    GetLearnedSkillLevel\r\n    GetRevivableUnit\r\n    GetRevivingUnit\r\n    GetAttacker\r\n    GetRescuer\r\n    GetDyingUnit\r\n    GetKillingUnit\r\n    GetDecayingUnit\r\n    GetSelectedUnit\r\n    GetConstructingStructure\r\n    GetCancelledStructure\r\n    GetConstructedStructure\r\n    GetResearchingUnit\r\n    GetResearched\r\n    GetTrainedUnitType\r\n    GetTrainedUnit\r\n    GetDetectedUnit\r\n    GetSummoningUnit\r\n    GetSummonedUnit\r\n    GetTransportUnit\r\n    GetLoadedUnit\r\n    GetSellingUnit\r\n    GetSoldUnit\r\n    GetBuyingUnit\r\n    GetSoldItem\r\n    GetChangingUnit\r\n    GetChangingUnitPrevOwner\r\n    GetManipulatingUnit\r\n    GetManipulatedItem\r\n    GetOrderedUnit\r\n    GetIssuedOrderId\r\n    GetOrderPointX\r\n    GetOrderPointY\r\n    GetOrderPointLoc\r\n    GetOrderTarget\r\n    GetOrderTargetDestructable\r\n    GetOrderTargetItem\r\n    GetOrderTargetUnit\r\n    GetSpellAbilityUnit\r\n    GetSpellAbilityId\r\n    GetSpellAbility\r\n    GetSpellTargetLoc\r\n    GetSpellTargetX\r\n    GetSpellTargetY\r\n    GetSpellTargetDestructable\r\n    GetSpellTargetItem\r\n    GetSpellTargetUnit\r\n    GetEventPlayerState\r\n    GetEventPlayerChatString\r\n    GetEventPlayerChatStringMatched\r\n    GetTriggerUnit\r\n    GetEventUnitState\r\n    GetEventDamage\r\n    GetEventDamageSource\r\n    GetEventDetectingPlayer\r\n    GetEventTargetUnit\r\n    GetWidgetLife\r\n    GetWidgetX\r\n    GetWidgetY\r\n    GetTriggerWidget\r\n    IsDestructableInvulnerable\r\n    GetDestructableTypeId\r\n    GetDestructableX\r\n    GetDestructableY\r\n    GetDestructableLife\r\n    GetDestructableMaxLife\r\n    GetDestructableOccluderHeight\r\n    GetDestructableName\r\n    GetTriggerDestructable\r\n    GetItemPlayer\r\n    GetItemTypeId\r\n    GetItemX\r\n    GetItemY\r\n    IsItemInvulnerable\r\n    IsItemVisible\r\n    IsItemOwned\r\n    IsItemPowerup\r\n    IsItemSellable\r\n    IsItemPawnable\r\n    IsItemIdPowerup\r\n    IsItemIdSellable\r\n    IsItemIdPawnable\r\n    EnumItemsInRect\r\n    GetItemLevel\r\n    GetItemType\r\n    GetItemName\r\n    GetItemCharges\r\n    GetItemUserData\r\n    GetUnitAcquireRange\r\n    GetUnitTurnSpeed\r\n    GetUnitPropWindow\r\n    GetUnitFlyHeight\r\n    GetUnitDefaultAcquireRange\r\n    GetUnitDefaultTurnSpeed\r\n    GetUnitDefaultPropWindow\r\n    GetUnitDefaultFlyHeight\r\n    GetHeroStr\r\n    GetHeroAgi\r\n    GetHeroInt\r\n    GetHeroXP\r\n    GetHeroSkillPoints\r\n    GetHeroLevel\r\n    GetUnitLevel\r\n    GetHeroProperName\r\n    IsSuspendedXP\r\n    GetUnitAbilityLevel\r\n    IsUnitPaused\r\n    GetUnitPointValue\r\n    GetUnitPointValueByType\r\n    GetUnitX\r\n    GetUnitY\r\n    GetUnitLoc\r\n    GetUnitFacing\r\n    GetUnitMoveSpeed\r\n    GetUnitDefaultMoveSpeed\r\n    GetUnitState\r\n    GetOwningPlayer\r\n    GetUnitTypeId\r\n    GetUnitRace\r\n    GetUnitName\r\n    GetUnitFoodUsed\r\n    GetUnitFoodMade\r\n    GetFoodMade\r\n    GetFoodUsed\r\n    GetUnitRallyPoint\r\n    GetUnitRallyUnit\r\n    GetUnitRallyDestructable\r\n    IsUnitInGroup\r\n    IsUnitInForce\r\n    IsUnitOwnedByPlayer\r\n    IsUnitAlly\r\n    IsUnitEnemy\r\n    IsUnitVisible\r\n    IsUnitDetected\r\n    IsUnitInvisible\r\n    IsUnitFogged\r\n    IsUnitMasked\r\n    IsUnitSelected\r\n    IsUnitRace\r\n    IsUnitType\r\n    IsUnit\r\n    IsUnitInRange\r\n    IsUnitInRangeXY\r\n    IsUnitInRangeLoc\r\n    IsUnitHidden\r\n    IsUnitIllusion\r\n    IsUnitInTransport\r\n    IsUnitLoaded\r\n    IsHeroUnitId\r\n    IsUnitIdType\r\n    GetUnitCurrentOrder\r\n    GetResourceAmount\r\n    WaygateGetDestinationX\r\n    WaygateGetDestinationY\r\n    WaygateSetDestination\r\n    WaygateIsActive\r\n    GetUnitUserData\r\n    IsPlayerAlly\r\n    IsPlayerEnemy\r\n    IsPlayerInForce\r\n    IsPlayerObserver\r\n    IsVisibleToPlayer\r\n    IsLocationVisibleToPlayer\r\n    IsFoggedToPlayer\r\n    IsLocationFoggedToPlayer\r\n    IsMaskedToPlayer\r\n    IsLocationMaskedToPlayer\r\n    GetPlayerRace\r\n    GetPlayerId\r\n    GetPlayerUnitCount\r\n    GetPlayerTypedUnitCount\r\n    GetPlayerStructureCount\r\n    GetPlayerState\r\n    GetPlayerScore\r\n    GetPlayerAlliance\r\n    GetPlayerHandicap\r\n    GetPlayerHandicapXP\r\n    GetPlayerTechMaxAllowed\r\n    GetPlayerTechResearched\r\n    GetPlayerTechCount\r\n    IsFogMaskEnabled\r\n    IsFogEnabled\r\n    VersionGet\r\n    GetFloatGameState\r\n    GetIntegerGameState\r\n    GetDefaultDifficulty\r\n    GetCustomCampaignButtonVisible\r\n    HaveStoredInteger\r\n    HaveStoredReal\r\n    HaveStoredBoolean\r\n    HaveStoredUnit\r\n    HaveStoredString\r\n    GetStoredInteger\r\n    GetStoredReal\r\n    GetStoredBoolean\r\n    GetStoredString\r\n    LoadInteger\r\n    LoadReal\r\n    LoadBoolean\r\n    LoadStr\r\n    LoadPlayerHandle\r\n    LoadWidgetHandle\r\n    LoadDestructableHandle\r\n    LoadItemHandle\r\n    LoadUnitHandle\r\n    LoadAbilityHandle\r\n    LoadTimerHandle\r\n    LoadTriggerHandle\r\n    LoadTriggerConditionHandle\r\n    LoadTriggerActionHandle\r\n    LoadTriggerEventHandle\r\n    LoadForceHandle\r\n    LoadGroupHandle\r\n    LoadLocationHandle\r\n    LoadRectHandle\r\n    LoadBooleanExprHandle\r\n    LoadSoundHandle\r\n    LoadEffectHandle\r\n    LoadUnitPoolHandle\r\n    LoadItemPoolHandle\r\n    LoadQuestHandle\r\n    LoadQuestItemHandle\r\n    LoadDefeatConditionHandle\r\n    LoadTimerDialogHandle\r\n    LoadLeaderboardHandle\r\n    LoadMultiboardHandle\r\n    LoadMultiboardItemHandle\r\n    LoadTrackableHandle\r\n    LoadDialogHandle\r\n    LoadButtonHandle\r\n    LoadTextTagHandle\r\n    LoadLightningHandle\r\n    LoadImageHandle\r\n    LoadUbersplatHandle\r\n    LoadRegionHandle\r\n    LoadFogStateHandle\r\n    LoadFogModifierHandle\r\n    LoadHashtableHandle\r\n    HaveSavedInteger\r\n    HaveSavedReal\r\n    HaveSavedBoolean\r\n    HaveSavedString\r\n    HaveSavedHandle\r\n    GetRandomInt\r\n    GetRandomReal\r\n    GetAllyColorFilterState\r\n    GetCreepCampFilterState\r\n    IsQuestRequired\r\n    IsQuestCompleted\r\n    IsQuestDiscovered\r\n    IsQuestFailed\r\n    IsQuestEnabled\r\n    IsQuestItemCompleted\r\n    IsTimerDialogDisplayed\r\n    IsLeaderboardDisplayed\r\n    IsMultiboardDisplayed\r\n    IsMultiboardMinimized\r\n    IsCineFilterDisplayed\r\n    GetCameraMargin\r\n    GetCameraBoundMinX\r\n    GetCameraBoundMinY\r\n    GetCameraBoundMaxX\r\n    GetCameraBoundMaxY\r\n    GetCameraField\r\n    GetCameraTargetPositionX\r\n    GetCameraTargetPositionY\r\n    GetCameraTargetPositionZ\r\n    GetCameraTargetPositionLoc\r\n    GetCameraEyePositionX\r\n    GetCameraEyePositionY\r\n    GetCameraEyePositionZ\r\n    GetCameraEyePositionLoc\r\n    GetSoundDuration\r\n    GetSoundFileDuration\r\n    GetSoundIsPlaying\r\n    GetSoundIsLoading\r\n    GetLightningColorA\r\n    GetLightningColorR\r\n    GetLightningColorG\r\n    GetLightningColorB\r\n    GetAbilityEffect\r\n    GetAbilityEffectById\r\n    GetAbilitySound\r\n    GetAbilitySoundById\r\n    GetTerrainCliffLevel\r\n    GetTerrainType\r\n    GetTerrainVariance\r\n    IsTerrainPathable\r\n    IsPointBlighted\r\n    IsNoVictoryCheat\r\n    IsNoDefeatCheat\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/peq/WurstScript/issues/comments/133725346","html_url":"https://github.com/peq/WurstScript/issues/379#issuecomment-133725346","issue_url":"https://api.github.com/repos/peq/WurstScript/issues/379","id":133725346,"user":{"login":"Frotty","id":1486037,"avatar_url":"https://avatars.githubusercontent.com/u/1486037?v=3","gravatar_id":"","url":"https://api.github.com/users/Frotty","html_url":"https://github.com/Frotty","followers_url":"https://api.github.com/users/Frotty/followers","following_url":"https://api.github.com/users/Frotty/following{/other_user}","gists_url":"https://api.github.com/users/Frotty/gists{/gist_id}","starred_url":"https://api.github.com/users/Frotty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Frotty/subscriptions","organizations_url":"https://api.github.com/users/Frotty/orgs","repos_url":"https://api.github.com/users/Frotty/repos","events_url":"https://api.github.com/users/Frotty/events{/privacy}","received_events_url":"https://api.github.com/users/Frotty/received_events","type":"User","site_admin":false},"created_at":"2015-08-22T16:43:42Z","updated_at":"2015-08-22T16:43:42Z","body":"Anything relying on such mechanics is obviously badly designed, but having a useless native call somewhere in your code, that gets removed and something changing in appearance, due to optimization, is way more likely, and actually kind of realistic (stuff like save/load that relies on seeds) than hitting the op limit.\r\n\r\nAlso hitting the op-limit cant really be be checked at compiletime.\r\n\r\n"}}