{"action":"created","issue":{"url":"https://api.github.com/repos/velinath/trinity-updater/issues/2","repository_url":"https://api.github.com/repos/velinath/trinity-updater","labels_url":"https://api.github.com/repos/velinath/trinity-updater/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/velinath/trinity-updater/issues/2/comments","events_url":"https://api.github.com/repos/velinath/trinity-updater/issues/2/events","html_url":"https://github.com/velinath/trinity-updater/issues/2","id":124103060,"number":2,"title":"Improve performance of config file merge","user":{"login":"velinath","id":6288119,"avatar_url":"https://avatars.githubusercontent.com/u/6288119?v=3","gravatar_id":"","url":"https://api.github.com/users/velinath","html_url":"https://github.com/velinath","followers_url":"https://api.github.com/users/velinath/followers","following_url":"https://api.github.com/users/velinath/following{/other_user}","gists_url":"https://api.github.com/users/velinath/gists{/gist_id}","starred_url":"https://api.github.com/users/velinath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/velinath/subscriptions","organizations_url":"https://api.github.com/users/velinath/orgs","repos_url":"https://api.github.com/users/velinath/repos","events_url":"https://api.github.com/users/velinath/events{/privacy}","received_events_url":"https://api.github.com/users/velinath/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/velinath/trinity-updater/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/velinath/trinity-updater/labels/wontfix","name":"wontfix","color":"ffffff"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-28T18:22:53Z","updated_at":"2016-06-13T14:03:06Z","closed_at":"2016-06-13T14:03:06Z","body":"Currently goes through all lines of the inner loop, starting from 1, each time around. If it is possible to not do this it would be best.\r\n\r\nThe best way to do this may be to create a variable or temp file with the contents of the old config file.\r\n```bash\r\ncp $SERVERDIR/etc/worldserver.conf $SERVERDIR/etc/worldserver.conf.tmp\r\n```\r\n\r\nThat way we can delete each line that we use so that it is no longer tested, i.e.\r\n```bash\r\nsed -i \"s/$oldline//\" $SERVERDIR/etc/worldserver.conf.tmp\r\n```\r\n\r\nThen just clean up at the end.\r\n```bash\r\nrm -f $SERVERDIR/etc/worldserver.conf.tmp\r\n```\r\n\r\nIn addition, if using temp files, we should delete the comments to save on for loop iterations. Maybe just go through once before we do the nested iterations.\r\n```bash\r\nif [[ ${oldline:0:1} == \"#\" ]] || [[ -z $oldline]]; then\r\n    sed -i \"s/$oldline//\" $SERVERDIR/etc/worldserver.conf.tmp\r\n    continue\r\nfi\r\n```\r\nI would just use an iterator but I can't guarantee that new config variables will always be created at the end of a file. Therefore this is probably best."},"comment":{"url":"https://api.github.com/repos/velinath/trinity-updater/issues/comments/225590056","html_url":"https://github.com/velinath/trinity-updater/issues/2#issuecomment-225590056","issue_url":"https://api.github.com/repos/velinath/trinity-updater/issues/2","id":225590056,"user":{"login":"velinath","id":6288119,"avatar_url":"https://avatars.githubusercontent.com/u/6288119?v=3","gravatar_id":"","url":"https://api.github.com/users/velinath","html_url":"https://github.com/velinath","followers_url":"https://api.github.com/users/velinath/followers","following_url":"https://api.github.com/users/velinath/following{/other_user}","gists_url":"https://api.github.com/users/velinath/gists{/gist_id}","starred_url":"https://api.github.com/users/velinath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/velinath/subscriptions","organizations_url":"https://api.github.com/users/velinath/orgs","repos_url":"https://api.github.com/users/velinath/repos","events_url":"https://api.github.com/users/velinath/events{/privacy}","received_events_url":"https://api.github.com/users/velinath/received_events","type":"User","site_admin":false},"created_at":"2016-06-13T14:03:06Z","updated_at":"2016-06-13T14:03:06Z","body":"Closing. I bashed my head against this long enough and the current implementation works. If anyone cares to try their hand at it open a PR and I'll test it on my dev box."}}
{"actor":{"display_login":"velinath"}}